PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

LoadAnimation

LoadAnimation will load the given Animation onto an Animator, returning a playable AnimationTrack. When called on Animators within models that the client has network ownership of, ie. the local player’s character or from BasePart/SetNetworkOwner, this function also loads the animation for the server as well.

You should use this function directly instead of the similarly-named Humanoid/LoadAnimation and AnimationController/LoadAnimation functions. These are deprecated proxies of this function which also create an Animator if one does not exist; this can cause replication issues if you are not careful. For more information, see this announcement post

Should I load an Animation on the client or server?

In order for AnimationTracks to replicate correctly, it’s important to know when they should be loaded on the client (via aLocalScript) or on the server (via a Script).

If an Animator is a descendant of a Humanoid or AnimationController in a Player’s Player/Character|Character then animations started on that Player’s client will be replicated to the server and other clients.

If the Animator is not a descendant of a player character, its animations must be loaded and started on the server to replicate.

The Animator object must be initially created on the server and replicated to clients for animation replication to work at all. If an Animator is created locally, then AnimationTracks loaded with that Animator will not replicate.

Both Humanoid/LoadAnimation and AnimationController/LoadAnimation will create an Animator if one does not already exist. When calling LoadAnimation from LocalScripts you need to be careful to wait for the Animator to replicate from the server before calling LoadAnimation if you want character animations to replicate. You can do this with WaitForChild(“Animator”).

See also

Parameters

Name Type Default Description

The Animation to be used.

Returns

Return Type Summary

Code Samples


Animating a Model Locally

This code sample includes a function that can be used to play an animation on a locally controlled model (such as a player character) from the server.