local buttonPressed = false
script.Parent.MouseButton1Click:connect(function()
if not buttonPressed then
buttonPressed = true
workspace.GiveRobux:FireServer()
wait(5)
buttonPressed = false
end
end)
✓ ANSWER ACCEPTED
The Debounce in my code between GiveRobux event Fired isn't work, How do I fix?
1 answer
✓ Accepted answer
Try changing the "if statement" to something like this:
local buttonPressed = false
script.Parent.MouseButton1Click:connect(function()
if buttonPressed == false then
buttonPressed = true
workspace.GiveRobux:FireServer()
wait(5)
buttonPressed = false
end
end)
so that way if the buttonPressed is equal true the if statement won't run
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Unless Workspace is a variable you set up, make sure it has a capital W, or it will stop the script when it reaches that point.
the capital W is deprecated, keep it lowercase.