This debounce doesn't work and I tried everything to fix it and it still doesn't work. PLEASE HELP!!!
local door = script.Parent.Parent.Door pressed = false function onClicked() if not pressed then pressed = true wait() for i = .25, 4 do door.CFrame = door.CFrame * CFrame.new(0, i, 0) wait(.05) print("yas") end door.Transparency = 1 pressed = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
In the future, you should consider giving at least a short summary of what exactly is not working in your script so that you can be better assisted. Anyway...
I modified your for
statement just tad because it seemed a bit 'iffy' to me. I also cleaned up your code every so slightly and adjusted the 'opening' or the door. I don't see anything wrong with the debounce, so perhaps there is another issue that is plaguing you if this new version does not work.
local door = script.Parent.Parent.Door pressed = false function onClicked() if pressed then return end pressed = true wait() for i = .25, 4, .05 do door.CFrame = door.CFrame * CFrame.new(0, i, 0) wait(0.01) end door.Transparency = 1 pressed = false end script.Parent.ClickDetector.MouseClick:connect(onClicked)