Here is a solution, Make a variable which is a number
local CoolDownSeconds = 0
Now make it check if that variable is 0.6 and if not then wait 0.6 seconds and change the variable
local CoolDownSeconds = 0
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
if CoolDownSeconds == 0.6 then
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play()
else
repeat
wait(0.1)
CoolDownSeconds = CoolDownSeconds + 0.1
until CoolDownSeconds == 0.6
if CoolDownSeconds == 0.6 then
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play()
CoolDownSeconds = 0
end
end
end)
end)
If you want a shorter version then here
local CoolDownSeconds = 0
script.Parent.Equipped:Connect(function(Mouse)
Mouse.Button1Down:Connect(function()
repeat
wait(0.1)
CoolDownSeconds = CoolDownSeconds + 0.1
until CoolDownSeconds == 0.6
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation)
animation:Play()
CoolDownSeconds = 0
end)
end)
Hope I helped and happy coding!
2 comments
Didn't quite work. Only delays the animation and is still spammable
Use debounce.