local Open = false local Button = script.Parent.Button.RedButton local Door1 = script.Parent.Door1 local Door2 = script.Parent.Door2 local Debouncer = false local cooldown = 1 --Change this for the door cooldown local closetime = 5 -- Change this to define how long until the door auto-closes local Light = script.Parent.Button.Light local OpenSound = script.Parent.Door1.Part.Sound local OverrideCheck = game.Workspace.Override.Value
function DoorOpen()
if game.Workspace.Override.Value == 0 then if Open == false and Debouncer == false then Light.BrickColor = BrickColor.new("Lime green") Open = true Debouncer = true --Is opening OpenSound:Play() for i = 1,30 do --opens Door1:SetPrimaryPartCFrame(Door1.PrimaryPart.CFrame * CFrame.new(0.2,0,0)) Door2:SetPrimaryPartCFrame(Door2.PrimaryPart.CFrame * CFrame.new(0.2,0,0)) wait() end wait(cooldown) Debouncer = false wait(closetime) if Open == true then Open = false Light.BrickColor = BrickColor.new("Lily white") OpenSound:Play() for i = 1,30 do --close Door1:SetPrimaryPartCFrame(Door1.PrimaryPart.CFrame * CFrame.new(-0.2,0,0)) Door2:SetPrimaryPartCFrame(Door2.PrimaryPart.CFrame * CFrame.new(-0.2,0,0)) wait() end end elseif Open == true and Debouncer == false then Light.BrickColor = BrickColor.new("Lily white") Debouncer = true --Is closing OpenSound:Play() Open = false for i = 1,30 do --close Door1:SetPrimaryPartCFrame(Door1.PrimaryPart.CFrame * CFrame.new(-0.2,0,0)) Door2:SetPrimaryPartCFrame(Door2.PrimaryPart.CFrame * CFrame.new(-0.2,0,0)) wait() end wait(cooldown) Debouncer = false end end end Button.ClickDetector.MouseClick:connect(DoorOpen)