Switching Player Animations

I need to update a players Freefall animation based on weather or not they are performing an action such as sky diving.

Setting the animation by running the following:

Character.Animate.fall.FallAnim.AnimationId = “idHere”

The animation doesn’t seem to update. Only after running the following does the animation actually update.

Character.Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
wait()
Character.Humanoid:ChangeState(Enum.HumanoidStateType.Freefall)

Am I missing something here? Is there a batter way to switch a characters animations so that it updates and replicates to all players? Can this be done all within a localscript or do should I run it from the server side?

3 Likes

Have you used :LoadAnimation to actually load the animation?

No i have not tried LoadAnimation() ill take a look at it

Also i only want to change the Falling animation and want it to return to a normal humanoid state once done

By extracting the animation script and overriding it, but also rewriting the corresponding piece of code, by parenting it under StarterCharacterScripts should do the trick.

The animation script can be acquired by using the explorer during a test session. Copy the script and then you’ll have it added to your clipboard. Then you’ll paste it and edit it, simply.

1 Like

The falling animation under character would only play once the state of the Humanoid is falling.
If you want to get back the original animation for the falling animation then cache it and replace it when you want to

You can initiate a Play Solo to retrieve the default animation script from the character, then parent it to StarterCharacterScripts. This script will be used and Roblox will not insert a default copy of it at runtime. I don’t recommend forking character scripts unless you’re rewriting code in it or making your own script, over changing a few values.

You also have the option of using the Humanoid Description System, for which you can overwrite animations without needing to fork any scripts. The way in which animations are fetched is a little strange and requires a bit more process, though it saves you code update trouble later.

And lastly, of course, you can set the AnimationIds of each animation in the script itself.

1 Like