--I also tried one from Dev Hub but that debounce didn't work either, have they updated this? and can someone link me a working debounce article or something
from dev hub:
local buttonPressed = false --Store whether the button is pressed in a local variable workspace.Button.Touched:Connect(function(hit) if not buttonPressed then -- Is it not pressed? buttonPressed = true -- Mark it as pressed, so that other handlers don't execute print("Button pressed") -- Do Stuff buttonPressed = false -- Mark it as not pressed, so other handlers can execute again end end)
This code prints it over and over again?? and the same thing with my test code (similar).
Hello.
That's because there is no wait in your debounce. Your value buttonPressed
will become instantly false and repeat if you are touching the brick.
Try this:
local buttonPressed = false workspace.Button.Touched:Connect(function(hit) if not buttonPressed then buttonPressed = true print("Touched!") wait(5) -- Delay buttonPressed = false end end)