Codectionary / Developer documentation / Luau

Animator and animation tracks

Load and play an animation through a character Animator.

Why use Animator?

Animator loads Animation objects and returns AnimationTracks that control playback. An animation asset must exist and be usable by the experience; this example intentionally has no invented asset ID.

Try it in Roblox Studio

Create an Animation named WaveAnimation under this LocalScript in StarterCharacterScripts and set its AnimationId to an animation your experience can use.

Syntax

local track = animator:LoadAnimation(animation)
track:Play()

Examples

Animator and animation tracks

Play a configured animation on the local character.

local humanoid = script.Parent:WaitForChild("Humanoid")
assert(humanoid:IsA("Humanoid"))
local animator = humanoid:WaitForChild("Animator")
local animation = script:WaitForChild("WaveAnimation")
assert(animator:IsA("Animator") and animation:IsA("Animation"))
local track = animator:LoadAnimation(animation)
track:Play()
  1. The Animator belongs to the character Humanoid, and AnimationId is supplied in Studio.
  2. LoadAnimation creates an AnimationTrack; Play begins its playback.
  3. The asset must be compatible with the character rig and permitted for the experience or no visible animation may result.

Best practices

  • Use an animation asset with the correct rig and permissions.
  • Manage track lifetime when replaying or replacing animations.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading