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

How to make a wait for a tool animation?

So i want to figure out how to make it so after you click a animation plays for the tool (simple right) so i did that but now the wait (.6 seconds) you can still spam click and have the animation play before the tool is ready to fire again.

is there a way to do this via using just wait(.6) or do i have to have extra lines of code?

3 answers

✓ Accepted answer
local isAnimating = false

local function yourFunction()
	if isAnimating == false then
		animation:Play()
		isAnimating = true
		animation.Stopped:wait() -- wait until this animation stopped!
		isAnimating = false
	end
end

You can use a variable to show if the animation is playing; and when the animation is done, you can do it again

You could add debounce,

local debounce = false

--your script
debounce = true
wait(.6)
debounce = false

Hi, i added debounce via the way you told me to. But i can still spam the animation.

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