--SECOND DOOR


local LMLOP2 = script.Parent.Door2.Left.LockMechanisms.LM.CFrame
local LMLTGP2 = script.Parent.Door2.Left.LockMechanisms.LMToGo.CFrame
local RMLOP2 = script.Parent.Door2.Right.LockMechanisms.LM.CFrame
local RMLTGP2 = script.Parent.Door2.Right.LockMechanisms.LMToGo.CFrame
local LDOP2 = script.Parent.Door2.Left.LeftDoor.CFrame
local LDTGP2 = script.Parent.Door2.Left.ToGoPos.CFrame
local RDOP2 = script.Parent.Door2.Right.RightDoor.CFrame
local RDTGP2 = script.Parent.Door2.Right.ToGoPos.CFrame

local function Cycle()
	script.Parent.LockShowA.BrickColor = BrickColor.new("Bright red")
	script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright red")
	script.Parent.LockShowC.BrickColor = BrickColor.new("Bright red")
	script.Parent.LockShowB.BrickColor = BrickColor.new("Bright red")
	script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright red")
	script.Parent.Fan1.Part.HingeConstraint.AngularVelocity=120
	script.Parent.Fan2.Part.HingeConstraint.AngularVelocity=120
	script.Parent.Fan1.Part.Smoke.Enabled=true
	script.Parent.Fan2.Part.Smoke.Enabled=true
	script.Parent.Airlocc.Sound:Play()
	wait(3)
	script.Parent.Fan1.Part.HingeConstraint.AngularVelocity=0
	script.Parent.Fan2.Part.HingeConstraint.AngularVelocity=0
	wait(2)
	script.Parent.Fan1.Part.Smoke.Enabled=false
	script.Parent.Fan2.Part.Smoke.Enabled=false
	script.Parent.LockShowA.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShowC.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShowB.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright green")
	wait(1)
end

local function CloseAll()
	local Main = "N/A"
	if DoorStatusA == "Opened" then
		script.Parent.Frame1.Union.OpenClose:Play()
		Globals.TweenModel(script.Parent.Door1.Left, LDOP,false,5.2)
		Globals.TweenModel(script.Parent.Door1.Right,RDOP,true,5.2)
		Globals.TweenModel(script.Parent.Door1.Left.LockMechanisms, LMLOP,false,1)
		Globals.TweenModel(script.Parent.Door1.Right.LockMechanisms,RMLOP,true,1)
		DoorStatusA = "Closed"
	end
	if DoorStatusB == "Opened" then
		script.Parent.Frame.Union.OpenClose:Play()
		Globals.TweenModel(script.Parent.Door2.Left, LDOP2,false,5.2)
		Globals.TweenModel(script.Parent.Door2.Right,RDOP2,true,5.2)
		Globals.TweenModel(script.Parent.Door2.Left.LockMechanisms, LMLOP2,false,1)
		Globals.TweenModel(script.Parent.Door2.Right.LockMechanisms,RMLOP2,true,1)
		DoorStatusB = "Closed"
	end
end

local function OpenAll()
	local Main = "N/A"
	if DoorStatusA == "Closed" then
		Globals.TweenModel(script.Parent.Door1.Left.LockMechanisms, LMLTGP,false,1)
		Globals.TweenModel(script.Parent.Door1.Right.LockMechanisms,RMLTGP,true,1)
		script.Parent.Frame1.Union.OpenClose:Play()	
		Globals.TweenModel(script.Parent.Door1.Left, LDTGP,false,5.2)	
		Globals.TweenModel(script.Parent.Door1.Right,RDTGP,true,5.2)
		DoorStatusA = "Opened"
	end
	if DoorStatusB == "Closed" then
		Globals.TweenModel(script.Parent.Door2.Left.LockMechanisms, LMLTGP2,false,1)
		Globals.TweenModel(script.Parent.Door2.Right.LockMechanisms,RMLTGP2,true,1)
		script.Parent.Frame.Union.OpenClose:Play()	
		Globals.TweenModel(script.Parent.Door2.Left, LDTGP2,false,5.2)	
		Globals.TweenModel(script.Parent.Door2.Right,RDTGP2,true,5.2)
		DoorStatusB = "Opened"
	end
end


local function OpenDoor1()
	if DoorStatusA == "Closed" then
		script.Parent.LockShowA.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShow2A.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShowC.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShowB.BrickColor = BrickColor.new("Bright red")
		script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright red")
		Globals.TweenModel(script.Parent.Door1.Left.LockMechanisms, LMLTGP,false,1)
		Globals.TweenModel(script.Parent.Door1.Right.LockMechanisms,RMLTGP,true,1)
		script.Parent.Frame1.Union.OpenClose:Play()	
		Globals.TweenModel(script.Parent.Door1.Left, LDTGP,false,5.2)	
		Globals.TweenModel(script.Parent.Door1.Right,RDTGP,true,5.2)
		DoorStatusA = "Opened"
		script.Parent.LockShowA.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShowC.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShowB.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright green")
	end
end
local function CloseDoor1()
	if DoorStatusA == 'Opened' then
		script.Parent.LockShowA.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShow2A.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShowC.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShowB.BrickColor = BrickColor.new("Bright red")
		script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright red")
		script.Parent.Frame1.Union.OpenClose:Play()
		Globals.TweenModel(script.Parent.Door1.Left, LDOP,false,5.2)
		Globals.TweenModel(script.Parent.Door1.Right,RDOP,true,5.2)
		Globals.TweenModel(script.Parent.Door1.Left.LockMechanisms, LMLOP,false,1)
		Globals.TweenModel(script.Parent.Door1.Right.LockMechanisms,RMLOP,true,1)
		DoorStatusA = "Closed"
		script.Parent.LockShowA.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShowC.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShowB.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright green")
	end
end
local function OpenDoor2()
	if DoorStatusB == "Closed" then
		script.Parent.LockShowB.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShow2B.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShowC.BrickColor = BrickColor.new("Deep orange")
		script.Parent.LockShowA.BrickColor = BrickColor.new("Bright red")
		script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright red")
		Globals.TweenModel(script.Parent.Door2.Left.LockMechanisms, LMLTGP2,false,1)
		Globals.TweenModel(script.Parent.Door2.Right.LockMechanisms,RMLTGP2,true,1)
		script.Parent.Frame.Union.OpenClose:Play()	
		Globals.TweenModel(script.Parent.Door2.Left, LDTGP2,false,5.2)	
		Globals.TweenModel(script.Parent.Door2.Right,RDTGP2,true,5.2)
		DoorStatusB = "Opened"
		script.Parent.LockShowB.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShowC.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShowA.BrickColor = BrickColor.new("Bright green")
		script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright green")
	end
end
local function CloseDoor2()
	script.Parent.LockShowB.BrickColor = BrickColor.new("Deep orange")
	script.Parent.LockShow2B.BrickColor = BrickColor.new("Deep orange")
	script.Parent.LockShowC.BrickColor = BrickColor.new("Deep orange")
	script.Parent.LockShowA.BrickColor = BrickColor.new("Bright red")
	script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright red")
	script.Parent.Frame.Union.OpenClose:Play()
	Globals.TweenModel(script.Parent.Door2.Left, LDOP2,false,5.2)
	Globals.TweenModel(script.Parent.Door2.Right,RDOP2,true,5.2)
	Globals.TweenModel(script.Parent.Door2.Left.LockMechanisms, LMLOP2,false,1)
	Globals.TweenModel(script.Parent.Door2.Right.LockMechanisms,RMLOP2,true,1)
	DoorStatusB = "Closed"
	script.Parent.LockShowB.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShow2B.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShowC.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShowA.BrickColor = BrickColor.new("Bright green")
	script.Parent.LockShow2A.BrickColor = BrickColor.new("Bright green")
end