Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The Debounce in my code between GiveRobux event Fired isn't work, How do I fix?

local buttonPressed = false

script.Parent.MouseButton1Click:connect(function()
	if not buttonPressed then
		buttonPressed = true
		workspace.GiveRobux:FireServer()
		wait(5)
		buttonPressed = false
	end
end)

2 comments

0

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.

0

the capital W is deprecated, keep it lowercase.

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.