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

How do I stop an animation then set an animation to play?

Asked by 7 years ago

Hello, In my game I have a script that replaces all the default animations and plays my custom ones.

game.Players.PlayerAdded:connect(function(player)
    while not player.Character do wait() end
    local character = player.Character
    local animateScript = character.Animate
    animateScript.idle.Animation2.AnimationId = 'http://www.roblox.com/asset/?id=633000480'
    animateScript.idle.Animation1.AnimationId = 'http://www.roblox.com/asset/?id=633000480'
    animateScript.fall.FallAnim.AnimationId = 'http://www.roblox.com/asset/?id=632774213'
    animateScript.jump.JumpAnim.AnimationId = 'http://www.roblox.com/asset/?id=632751324'
    animateScript.walk.WalkAnim.AnimationId = 'http://www.roblox.com/asset/?id=631862913'
end)

How do I make it so that when a press a certain key that all of these animations will stop and play another animation?

So if i press "z" all of these animations will stop playing and another animation will play (and also set the player's speed to zero) Then after the animation is dont playing once reactivate all of the other animations and deactivate this one?

Thanks -UnbeatableChicken

0
you wanna accept mah answer Shawnyg 4330 — 7y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
7 years ago

To stop an animation, read this wiki post. Read up on UserInputService to manage key presses.

Here's how to approach it:

When the Z key is pressed, Stop any current animation, set the WalkSpeed to 0, Play the animation wait for the event Stopped to be fired, then replace all of the values.

0
ok lemme try BeatableChicken 2 — 7y
0
actually what i did was i set the animation priority to action in animation editor. It worked. How did i not think of that before BeatableChicken 2 — 7y
0
o or that works. I literally did what your question said Shawnyg 4330 — 7y
Ad

Answer this question