How to change animation depending on walkspeed?

The character gradually gains speed, going from a jog to a sprint in about 3 seconds while holding any direction. I want the animation to change to my running animation when their walkspeed is over 30, but changing the animation ID doesn’t work and results in an error

4 Likes

Don’t change the ID.
You can set priorities for animations within the animation editor as well as
When running you have to run the running animationWhen running you have to run the running animation.

2 Likes

Some of this code is in the Animate script provided by Roblox. You have to either edit these sections, or disable Animate and make a new one.

There are a lot of sections relating to run and walk speed/animations (approximate locations, my script is modified):

Lines 330 - 390, 480 - 490, 570 - 585, 690-691

This script will compete with anything you write.

1 Like

You could use my version of the Animate script, which allows you to change animation ID’s at runtime. Then you just need to run:

R15
game:GetService("ReplicatedStorage"):WaitForChild("Animate2").Animations.RunningAnim.Value = YourIdHere
R6
game:GetService("ReplicatedStorage"):WaitForChild("Animate2")["Animations R6"].RunningAnim.Value = YourIdHere

to change the animation after calculating which one you want.

3 Likes