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 8 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 — 8y
0
Sadly I can't upvote your comment, but thank you very much HospitalDev that's exactly what I needed. JohnnyS_Sinns 27 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

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

Example:

01local debounce = false
02 
03script.Parent.Touched:connect(function(playerWhoTouched)
04    if not debounce then --If the debounce isn't activated
05        debounce = true --Activate it
06        print("TOUCHED")
07        wait(5)
08        debounce = false --Deactivate It
09    end
10end)

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

Ad

Answer this question