Ad
Log in to vote
0

How to make a wait for a tool animation?

Asked by 5 months ago

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

Log in to vote
0
Answered by 5 months ago
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

Ad
Log in to vote
0
Answered by 5 months ago

You could add debounce,

local debounce = false

--your script
debounce = true
wait(.6)
debounce = false
Log in to vote
0
Answered by 5 months ago

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

Answer this question