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

Debounce isnt working? Can Spam Click

Asked by 5 years ago

Pretty much a tool and when you click it plays an animation. Plan for it to do more but I can't because the debounce doesn't work. Pretty much you can spam click and the animation plays as fast as you click. I do not see where I am failing here but i'm lost now. It's in a local script in a tool.

Here it is:

local rep = game:GetService("ReplicatedStorage")
local deb = false

script.Parent.Equipped:Connect(function(Mouse)
    Mouse.Button1Down:Connect(function()
        if deb == false then
            deb =true
            script.Parent.Handle.Transparency = 0
            animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
            animation:Play()
            wait(1.2)
            script.Parent.Handle.Transparency = 1
            rep.Make:FireServer()
        end
        wait(2)
        deb = false
    end)
end)

script.Parent.Unequipped:Connect(function()
    animation:Stop()
end)

Any help is appreciated

0
use if deb == false then *code* else wait(2) deb = false greatneil80 2647 — 5y
1
Put the wait(2) and deb = false inside the if statement for the deb MrLonely1221 701 — 5y
0
if deb == false then return end DeceptiveCaster 3761 — 5y
0
doing deb == false then won't work DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by
Hizar7 102
5 years ago

Try to remove the animation and see if it works, if it does then im not sure how to fix it, but i do know I had a similar issue & had to use two different script, let me know

0
The reason why i believe this is the issue is because your debounce is placed right but inside the script is a wait of 1.2 seconds, Inside that 1.2 seconds you'll be able to spam click the function while the animation plays Hizar7 102 — 5y
Ad

Answer this question