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

Debounce isnt working? Can Spam Click

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

4 comments

0

use if deb == false then code else wait(2) deb = false

1

Put the wait(2) and deb = false inside the if statement for the deb

0

if deb == false then return end

0

doing deb == false then won't work

1 answer

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

1 comment

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

This discussion is preserved as it was. New answers, comments, and votes are closed.