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 6 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 — 6y
0
the capital W is deprecated, keep it lowercase. Perci1 4988 — 6y

1 answer

Log in to vote
1
Answered by
sad_eyez 162
6 years ago
Edited 6 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