So I made this moving door script: when you touch a button, the door moves waits then moves back and I tried using the wiki to debounce it now after the firstn activation the button works normally but then onwards the button becomes possible to activate earlier than supposed making the door move farther:
local buttonPressed = false
script.Parent.Touched:connect(function(move)
if not buttonPressed then
buttonPressed = true
script.Parent.BrickColor = BrickColor.new(21)
local wall = script.Parent.Parent.wall.wall
local dis =150
for i=0, dis do
wall.CFrame = wall.CFrame + Vector3.new(0,0,0.2)
wait()
end
wait(5)
for i=0, dis do
wall.CFrame = wall.CFrame + Vector3.new(0,0,-0.2)
wait()
end
end
wait(20)
script.Parent.BrickColor = BrickColor.new(309)
buttonPressed = false
end)

1 comment
Ooooh I see it now, thanks! I just began learning scripting and my scripts are kind of messy. Thanks for the help! :)