Hello, so My door system works basically with motors, but i’ve been having a trouble,because if you spam the doors it starts acting REALLY weird, I think it’s because the delay(8,function() that checks if door’s open and close it
for i,v in ipairs(workspace.Map.Chunk1.Doors:GetChildren()) do
doordebounce[v] = false
if v.Name == "SingleDoor" then
v.Moving.ClickDetector.MouseClick:Connect(function(Player)
local Position = v.Moving.Door.CFrame:PointToObjectSpace(Player.Character.HumanoidRootPart.Position)
if v.Open.Value == false and doordebounce[v] == false then
v.Open.Value = true
doordebounce[v] = true
v.Important["Door Opening"]:Play()
if Position.Z < 0 then
v.Moving.Primary.Motor.DesiredAngle = 1.4
elseif Position.Z > 1 then
v.Moving.Primary.Motor.DesiredAngle = -1.4
end
elseif v.Open.Value == true and doordebounce[v] == false then
v.Moving.Primary.Motor.DesiredAngle = 0
v.Open.Value = false
end
delay(8, function()
if v.Open.Value == true then
v.Open.Value = false
v.Moving.Primary.Motor.DesiredAngle = 0
doordebounce[v] = false
end
end)
wait(1)
doordebounce[v] = false
end)
elseif v.Name == "DoubleDoor" then
v.Moving.ClickDetector.MouseClick:Connect(function(Player)
local Position = v.Moving.Door.CFrame:PointToObjectSpace(Player.Character.HumanoidRootPart.Position)
if v.Open.Value == false and doordebounce[v] == false then
v.Open.Value = true
if Position.Z < 1 then
v.Moving.Primary.Motor.DesiredAngle = 1.4
v.Moving.Primary1.Motor.DesiredAngle = -1.4
elseif Position.Z > 1 then
v.Moving.Primary1.Motor.DesiredAngle = 1.4
v.Moving.Primary.Motor.DesiredAngle = -1.4
end
elseif v.Open.Value == true and doordebounce[v] then
v.Moving.Primary.Motor.DesiredAngle = 0
v.Moving.Primary1.Motor.DesiredAngle = 0
v.Open.Value = false
end
delay(8, function()
if v.Open.Value == true then
v.Open.Value = false
v.Moving.Primary.Motor.DesiredAngle = 0
v.Moving.Primary1.Motor.DesiredAngle = 0
doordebounce[v] = false
end
end)
wait(1)
doordebounce[v] = false
end)
end
end