Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 7 years ago
local buttonPressed = false

script.Parent.MouseButton1Click:connect(function()
    if not buttonPressed then
        buttonPressed = true
        workspace.GiveRobux:FireServer()
        wait(5)
        buttonPressed = false
    end
end)
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. commag 228 — 7y
0
the capital W is deprecated, keep it lowercase. Perci1 4988 — 7y

1 answer

Log in to vote
1
Answered by
sad_eyez 162
7 years ago
Edited 7 years ago

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

Ad

Answer this question