Animation

Show Deprecated

An object that references an animation asset (AnimationId) which can be loaded by a Humanoid or AnimationController.

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 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:

Code Samples

Animation Creation

1local Players = game:GetService("Players")
2
3local player = Players:FindFirstChild("Builderman")
4
5local character = player.Character
6local humanoid = character:FindFirstChild("Humanoid")
7
8local animation = Instance.new("Animation")
9animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emote
10
11local animationTrack = humanoid:LoadAnimation(animation)
12animationTrack:Play()

Summary

Properties

Content ID of the animation an Animation object is referencing. Once an animation has been created and uploaded to Roblox the content ID can be found in the uploaded animation's URL.

Events

Methods

Properties

AnimationId

This property is the content ID of the animation an Animation object is referencing. Once an animation has been created and uploaded to Roblox the content ID can be found in the uploaded animation's URL.

This URL is presented immediately after an animation has been uploaded to Roblox, in the Animation Editor export window. It can also be found in the Develop tab on the Roblox site, under 'Animations'.

It's important to remember the URL is not the same as the content ID. It will work when pasted directly into the AnimationId property of an Animation in Roblox studio, as Studio will automatically correct it, however if it is being set from a Script then the correct content ID will need to be used, using the number from the URL. For example:


1"https://www.roblox.com/catalog/507771019" -- Web URL (will not work)
2"http://www.roblox.com/asset/?id=507771019" -- Content ID (will work)
3"rbxassetid://507771019" -- Content ID (alternative version, will work)
4

Note, the animation will need to be loaded onto an AnimationTrack in order to play it.

Events

Methods