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

This function loads an Animation onto an AnimationController, returning an AnimationTrack that can be used for playback.

How to load an Animation

The following code can be used to load an Animation onto an AnimationController.

local animationTrack = animationController:LoadAnimation(animation)
animationTrack:Play()

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


Using an AnimationController to animation non-player objects

This code sample demonstrates how an AnimationController can be used in place of a Humanoid for non player character objects.

A basic rig is loaded using InsertService and the default Humanoid is replaced with an AnimationController. An AnimationTrack is then created and played.