Collapse Sidebar


This function changes the AnimationTrack/Speed of an animation. A positive value for speed plays the animation forward, a negative one plays it backwards, and 0 pauses it.

An AnimationTrack’s initial speed is set as a parameter in AnimationTrack/Play. However a track’s Speed can be changed during playback, using AdjustSpeed. When speed is equal to 1, the amount of time an animation takes to complete is equal to AnimationTrack/Length (in seconds).

When is adjusted, then the actual time it will take a track to play can be computed by dividing the length by the speed. Speed is a unitless quantity.

Speed can be used to link the length of an animation to different gameplay events (for example recharging an ability) without having to upload different variants of the same animation.


Name Type Default Description

The playback speed the animation is to be changed to.


Return Type Summary

Code Samples

Playing Animation for a Specific Duration

The following function will play an AnimationTrack for a specific duration. This is done by changing the speed of the animation to the length of the animation divided by the desired playback duration. This could be used in situations where a developer wants to play a standard animation for different duration (for example, recharging different abilities).

function playAnimationForDuration(animationTrack, duration)
	local speed = animationTrack.Length / duration

Animation Speed

In this example a player and an animation is loaded. The Length of an AnimationTrack determines how long the track would take to play if the speed is at 1. If the speed is adjusted, then the actual time it will take a track to play can be computed by dividing the length by the speed.

local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
while not localPlayer.Character do wait() end
local character = localPlayer.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://507770453"
local animationTrack = humanoid:LoadAnimation(animation)
local normalSpeedTime = animationTrack.Length / animationTrack.Speed
local fastSpeedTime = animationTrack.Length / animationTrack.Speed
print("At normal speed the animation will play for", normalSpeedTime, "seconds")
print("At 3x speed the animation will play for", fastSpeedTime, "seconds")