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

How can I prevent the "reset" of one animation?

Asked by 7 years ago

Hello ScriptingHelpers,

This is a simple question but not too simple for me. How can I prevent the "reset" of one animation?

I mean, I have an animation, when I press Space the animation starts. If I press Space multiple times the Animation stops and start again and looks pretty bad.

I want that if the Player hits the Space multiple times don't do anything before the Animation ends.

I was thinking about using the wait() function but I don't really know how to implement that with animations.

I really appreciate any help you can provide.

2
Use debounces TheHospitalDev 1134 — 7y
0
Sadly I can't upvote your comment, but thank you very much HospitalDev that's exactly what I needed. JohnnyS_Sinns 27 — 7y

1 answer

Log in to vote
2
Answered by 7 years ago

Debounces are a good way of doing this, as with the touched event.

Example:

local debounce = false

script.Parent.Touched:connect(function(playerWhoTouched)
    if not debounce then --If the debounce isn't activated
        debounce = true --Activate it
        print("TOUCHED")
        wait(5)
        debounce = false --Deactivate It
    end
end)

To those who look at this answer, please excuse my wording!

Ad

Answer this question