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

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

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

1 comment

0

you wanna accept mah answer

1 answer

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.

3 comments

0

ok lemme try

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

0

o or that works. I literally did what your question said

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