# AnimationTrack

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable
- Memory category: Animation
- HTML page: https://rapi.sleaze.dev/classes/AnimationTrack/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/AnimationTrack

Controls the playback of an animation on an [`Animator`](https://rapi.sleaze.dev/classes/Animator.md).

## Properties

### Animation

```luau
AnimationTrack.Animation: Animation
```

- Tags: Read only, Read capabilities: Animation

The [`Animation`](https://rapi.sleaze.dev/classes/Animation.md) object that was used to create this [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

### IsPlaying

```luau
AnimationTrack.IsPlaying: boolean
```

- Tags: Read only, Read capabilities: Animation, Simulation access

A read-only property that returns true when the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) is playing.

### Length

```luau
AnimationTrack.Length: number
```

- Tags: Read only, Read capabilities: Animation

A read-only property that returns the length (in seconds) of an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md). This will return `0` until the animation has fully loaded and thus may not be immediately available.

### Looped

```luau
AnimationTrack.Looped: boolean
```

- Tags: Read capabilities: Animation, Simulation access

Sets whether the animation will repeat after finishing. If it is changed while playing the result will take effect after the animation finishes.

### Priority

```luau
AnimationTrack.Priority: Enum.AnimationPriority
```

- Tags: Read capabilities: Animation, Simulation access

Sets the priority of an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md). Depending on what this is set to, playing multiple animations at once will look to this property to figure out which [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md) `Poses` should be played over one another.

### Speed

```luau
AnimationTrack.Speed: number
```

- Tags: Read only, Read capabilities: Animation, Simulation access

Read-only property that gives the current playback speed of the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

### TimePosition

```luau
AnimationTrack.TimePosition: number
```

- Tags: Not replicated, Read capabilities: Animation, Load only, Simulation access

Returns the position in time in seconds that an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) is through playing its source animation. Can be set to make the track jump to a specific moment in the animation.

### WeightCurrent

```luau
AnimationTrack.WeightCurrent: number
```

- Tags: Read only, Read capabilities: Animation, Simulation access

Read-only property that gives the current weight of the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

### WeightTarget

```luau
AnimationTrack.WeightTarget: number
```

- Tags: Read only, Read capabilities: Animation, Simulation access

Read-only property that gives the current weight of the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

## Methods

### AdjustSpeed

```luau
AnimationTrack:AdjustSpeed(speed: number? = 1)
```

- Tags: Custom Lua state, Capabilities: Animation, Simulation access

Changes the [`AnimationTrack.Speed`](https://rapi.sleaze.dev/classes/AnimationTrack.md) of an animation. A positive value for speed plays the animation forward, a negative one plays it backwards, and `0` pauses it.

Parameters:

- `speed`: The playback speed the animation is to be changed to.

### AdjustWeight

```luau
AnimationTrack:AdjustWeight(weight: number? = 1, fadeTime: number? = 0.100000001)
```

- Tags: Custom Lua state, Capabilities: Animation, Simulation access

Changes the weight of an animation, with the optional `fadeTime` parameter determining how long it takes for [`AnimationTrack.WeightCurrent`](https://rapi.sleaze.dev/classes/AnimationTrack.md) to reach [`AnimationTrack.WeightTarget`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

Parameters:

- `weight`: The weight the animation is to be changed to.
- `fadeTime`: The duration of time that the animation will fade between the old weight and the new weight for.

### GetDebugData

```luau
AnimationTrack:GetDebugData(): { [string]: any }
```

- Tags: Roblox script security, Capabilities: Animation

### GetMarkerReachedSignal

```luau
AnimationTrack:GetMarkerReachedSignal(name: string): RBXScriptSignal
```

- Tags: Capabilities: Animation

Returns an [`RBXScriptSignal`](https://rapi.sleaze.dev/index/types/RBXScriptSignal.md) (event) that fires when a specified [`KeyframeMarker`](https://rapi.sleaze.dev/classes/KeyframeMarker.md) has been hit in an `animation`.

Parameters:

- `name`: The name of the [`KeyframeMarker`](https://rapi.sleaze.dev/classes/KeyframeMarker.md) the signal is being created for. Not to be confused with the name of the [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md).

Returns: The signal created and fired when the animation reaches the created [`KeyframeMarker`](https://rapi.sleaze.dev/classes/KeyframeMarker.md).

### GetParameter

```luau
AnimationTrack:GetParameter(key: string): any
```

- Tags: Capabilities: Animation, Simulation access

Returns the value of a parameter on the animation graph by key. Returns nil if the parameter has not been set.

Parameters:

- `key`: The name of the parameter to retrieve.

Returns: The current value of the parameter, or nil if not set.

### GetParameterDefaults

```luau
AnimationTrack:GetParameterDefaults(): { [string]: any }
```

- Tags: Capabilities: Animation

Returns a dictionary of parameter values initially set as instance attributes on the [`AnimationGraphDefinition`](https://rapi.sleaze.dev/classes/AnimationGraphDefinition.md) instance used to build the animation graph inside this track.

Returns: A dictionary mapping parameter names to their default values. Returns an empty dictionary if the animation is not an animation graph.

### GetTargetInstance

```luau
AnimationTrack:GetTargetInstance(name: string): Instance
```

- Tags: Capabilities: Animation

### GetTargetNames

```luau
AnimationTrack:GetTargetNames(): { any }
```

- Tags: Capabilities: Animation

### GetTimeOfKeyframe

```luau
AnimationTrack:GetTimeOfKeyframe(keyframeName: string): number
```

- Tags: Capabilities: Animation

Returns the time position of the first [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md) of the given name in an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

Parameters:

- `keyframeName`: The name associated with the [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md) to be found.

Returns: The time, in seconds, the [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md) occurs at normal playback speed.

### Play

```luau
AnimationTrack:Play(fadeTime: number? = 0.100000001, weight: number? = 1, speed: number? = 1)
```

- Tags: Custom Lua state, Capabilities: Animation, Simulation access

Plays the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md). Once called an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) will play with the specified `fadeTime`, weight and speed.

Parameters:

- `fadeTime`: The duration of time that the animation's weight should be faded in for.
- `weight`: The weight the animation is to be played at.
- `speed`: The playback speed of the animation.

### ResetGraph

```luau
AnimationTrack:ResetGraph()
```

- Tags: Roblox script security, Capabilities: Animation

### SetParameter

```luau
AnimationTrack:SetParameter(key: string, value: any)
```

- Tags: Capabilities: Animation, Simulation access

Sets a parameter value on the animation graph, driving animation graph node inputs.

Parameters:

- `key`: The name of the parameter to set.
- `value`: The value to assign to the parameter. Non-finite numeric values are sanitized to 0.

### SetTargetInstance

```luau
AnimationTrack:SetTargetInstance(name: string, target: Instance)
```

- Tags: Capabilities: Animation

### Stop

```luau
AnimationTrack:Stop(fadeTime: number? = 0.100000001)
```

- Tags: Custom Lua state, Capabilities: Animation, Simulation access

Stops the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md).

Parameters:

- `fadeTime`: The time, in seconds, for which animation weight is to be faded out over.

### UpdateGraphNodeDefinition

```luau
AnimationTrack:UpdateGraphNodeDefinition(nodeId: string, nodeDefinition: Instance): boolean
```

- Tags: Roblox script security, Capabilities: Animation

### UpdateGraphNodeProperty

```luau
AnimationTrack:UpdateGraphNodeProperty(nodeId: string, propertyName: string, value: any, inputPinName: string? = ""): boolean
```

- Tags: Roblox script security, Capabilities: Animation

## Events

### DidLoop

```luau
AnimationTrack.DidLoop: RBXScriptSignal<()>
```

- Tags: Capabilities: Animation

Fires when an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) loops on the next update following the end of the previous animation loop.

### Ended

```luau
AnimationTrack.Ended: RBXScriptSignal<()>
```

- Tags: Capabilities: Animation

Fires when the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) is completely done moving anything in the world.

### KeyframeReached

```luau
AnimationTrack.KeyframeReached: RBXScriptSignal<(keyframeName: string)>
```

- Tags: Capabilities: Animation

Fires every time playback of an [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) reaches a [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md) that does not have the default name of [`Keyframe`](https://rapi.sleaze.dev/classes/Keyframe.md).

### ParameterChanged

```luau
AnimationTrack.ParameterChanged: RBXScriptSignal<(key: string, value: any)>
```

- Tags: Roblox script security, Capabilities: Animation

### Stopped

```luau
AnimationTrack.Stopped: RBXScriptSignal<()>
```

- Tags: Capabilities: Animation

Fires when the [`AnimationTrack`](https://rapi.sleaze.dev/classes/AnimationTrack.md) finishes playing. The AnimationTrack might still animate the subject while the animation "fades out". To catch when the AnimationTrack is completely done moving anything in the world, use the [`AnimationTrack.Ended`](https://rapi.sleaze.dev/classes/AnimationTrack.md) event.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
