I am having an issue where if you were to spam open and close the door doe six seconds the statement after wait(6) is true and will cause the door to instantly close when you open it. Is there a way to cancel the function if the door is manually closed before the check occurs?
local Door = game.ReplicatedStorage.Door
local function Operate(door)
if door.Open.Value == false then
door.Open.Value = true
if door:FindFirstChild("Left") then
door.Left.Anchor.Motor.DesiredAngle = -1.5
end
if door:FindFirstChild("Right")then
door.Right.Anchor.Motor.DesiredAngle = 1.5
end
door.Sound.Open:Play()
else
door.Open.Value = false
if door:FindFirstChild("Left") then
door.Left.Anchor.Motor.DesiredAngle = 0
end
if door:FindFirstChild("Right") then
door.Right.Anchor.Motor.DesiredAngle = 0
end
door.Sound.Close:Play()
end
wait(6)
if door.Open.Value == true then
door.Open.Value = false
if door:FindFirstChild("Left") then
door.Left.Anchor.Motor.DesiredAngle = 0
end
if door:FindFirstChild("Right") then
door.Right.Anchor.Motor.DesiredAngle = 0
end
door.Sound.Close:Play()
end
end
Door.OnServerEvent:Connect(function(plr, door)
Operate(door)
end)