Skip to main content

Animation

Methods for specific Blockbench animations

For all examples on this page assume

local myAnim = animations.myModel.myAnimation

(and that this is a valid animation path)

For an explanation on indexing animations, see the Animations Tutorial


Play/Stop

play()

Initializes the animation

Resume the animation if it was paused

play()

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:play()

stop()

Stop the animation

stop()

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:stop()

pause()

Pause the animation's playback

pause()

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:pause()

restart()

Restarts the animation

Plays the animation if it was stopped

This behavior can also be reproduced by stopping then playing the animation

restart()

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:restart()

setPlaying()

Aliases: playing()

A function that merges "play" and "stop" together

Takes a boolean parameter, where if true, the animation will play, and when false, the animation will stop

setPlaying(bool)

Parameters:

NameTypeDescriptionDefault
boolBooleanTrue or false value that dictates if the animation will play or stopfalse

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example (Overload 2):

-- This example would be in a function like a tick event
local crouching = player:getPose() == "CROUCHING"
myAnim:setPlaying(crouching)

isPlaying()

Checks if the animation is playing

isPlaying()

Returns:

TypeDescription
BooleanReturns true if the animation is playing, and false if it isn't

Example:

myAnim:isPlaying()

isStopped()

Checks if the animation is stopped

isStopped()

Returns:

TypeDescription
BooleanReturns true if the animation is stopped, and false if it isn't

Example:

myAnim:isStopped()

isPaused()

Checks if the animation is paused

isPaused()

Returns:

TypeDescription
BooleanReturns true if the animation is paused, and false if it isn't

Example:

myAnim:isPaused()

getPlayState()

Get the animation's playback state

getPlayState()

Returns:

TypeDescription
StringReturns the PlayState

Example:

myAnim:getPlayState()

Timing

setSpeed()

Aliases: speed()

Sets the animation's playback speed

Negative numbers can be used for an inverted animation

Default speed is 1, 2 is twice the speed, and 0.5 is half the speed

setSpeed(speed)

Parameters:

NameTypeDescriptionDefault
speedNumberSets the animation's speed1

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setSpeed(2)

getSpeed()

Gets the animation's speed

getSpeed()

Returns:

TypeDescription
NumberThe animation's speed as a number

Example:

myAnim:getSpeed()

setLength()

Aliases: length()

Set the animation's length, in seconds

setLength(length)

Parameters:

NameTypeDescriptionDefault
lengthNumberThe length of time, in seconds0

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setLength(2)

getLength()

Gets the animation's length, in seconds

getLength()

Returns:

TypeDescription
NumberReturns the animation's length, in seconds

Example:

myAnim:getLength()

setPriority()

Aliases: priority()

Sets the animation's priority

Instead of blending, low priority animations are overridden by high priority ones

The default priority of animations is 0

setPriority(priority)

Parameters:

NameTypeDescriptionDefault
priorityIntegerThe priority of the animation, as a whole number0

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setPriority(1)

getPriority()

Gets the animation's priority

getPriority()

Returns:

TypeDescription
IntegerReturns the animation's priority number

Example:

myAnim:getPriority()

setTime()

Aliases: time()

Sets the animation's playback current time, in seconds

setTime(time)

Parameters:

NameTypeDescriptionDefault
timeNumberThe time to set the animation to, in seconds0

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setTime(1.5)

getTime()

Get the animation's playback current time, in seconds

getTime()

Returns:

TypeDescription
NumberReturns the playback time of the animation

Example:

myAnim:getTime()

setOffset()

Aliases: offset()

Sets how much time to skip for the animation, in seconds

The time is skipped on every loop

setOffset(offset)

Parameters:

NameTypeDescriptionDefault
offsetNumberTime in seconds to skip for each loop0

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setOffset(1.75)

getOffset()

Gets the animation's offset time, in seconds

getOffset()

Returns:

TypeDescription
NumberThe time that is skipped every loop, in seconds

Example:

myAnim:getOffset()

setLoop()

Aliases: loop()

Sets the animation's loop mode

setLoop(loop)

Parameters:

NameTypeDescriptionDefault
loopStringSets the LoopModeRequired

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setLoop("ONCE")

getLoop()

Gets the animation's loop mode

getLoop()

Returns:

TypeDescription
StringReturns the LoopMode

Example:

myAnim:getLoop()

setBlend()

Aliases: blend()

Sets the animation's keyframe blend factor, which is the strength of the animation

setBlend(blend)

Parameters:

NameTypeDescriptionDefault
blendNumberStrength of the blend factor between 0 and 11

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setBlend(.5)

getBlend()

Gets the animation's keyframe blend factor, which is the strength of the animation

getBlend()

Returns:

TypeDescription
NumberGets the strength of the blend factor between 0 and 1

Example:

myAnim:getBlend()

setStartDelay()

Aliases: startDelay()

Set how much time to wait before this animation is initialized, in seconds

Note that while it is waiting, the animation is considered being played

setStartDelay(delay)

Parameters:

NameTypeDescriptionDefault
delayNumberThe time in seconds to set the delay to0

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setStartDelay(1)

getStartDelay()

Gets the animation's start delay, in seconds

getStartDelay()

Returns:

TypeDescription
NumberThe time in seconds that it's being delayed

Example:

myAnim:getStartDelay()

setLoopDelay()

Aliases: loopDelay()

Set how much time to wait in between the loops of this animation, in seconds

setLoopDelay(delay)

Parameters:

NameTypeDescriptionDefault
delayNumberThe time in seconds to set the delay to0

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setLoopDelay(1)

getLoopDelay()

Gets the animation's loop delay, in seconds

getLoopDelay()

Returns:

TypeDescription
NumberThe time in seconds that it's being delayed

Example:

myAnim:getLoopDelay()

Overriding

setOverride()

Aliases: override()

Set if this animation should override all of its parts vanilla transforms

Equivalent of calling "overrideRot", "overridePos" and "overrideScale" altogether

setOverride(override)

Parameters:

NameTypeDescriptionDefault
overrideBooleanTrue or false if it should or shouldn't override all transformationsfalse

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setOverride(true)

setOverrideRot()

Aliases: overrideRot()

Set if this animation should override its parts vanilla rotation

setOverrideRot(override)

Parameters:

NameTypeDescriptionDefault
overrideBooleanTrue or false if it should or shouldn't override rotationfalse

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setOverrideRot(true)

getOverrideRot()

Gets if this animation should override its parts vanilla rotation

getOverrideRot()

Returns:

TypeDescription
BooleanReturns if it should be overriding rotation

Example:

myAnim:getOverrideRot()

setOverridePos()

Aliases: overridePos()

Set if this animation should override its parts vanilla position

setOverridePos(override)

Parameters:

NameTypeDescriptionDefault
overrideBooleanTrue or false if it should or shouldn't override positionfalse

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setOverridePos(true)

getOverridePos()

Gets if this animation should override its parts vanilla position

getOverridePos()

Returns:

TypeDescription
BooleanReturns if it should be overriding position

Example:

myAnim:getOverridePos()

setOverrideScale()

Aliases: overrideScale()

Set if this animation should override its parts vanilla scale

setOverrideScale(override)

Parameters:

NameTypeDescriptionDefault
overrideBooleanTrue or false if it should or shouldn't override scalefalse

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:setOverrideScale(true)

getOverrideScale()

Gets if this animation should override its parts vanilla scale

getOverrideScale()

Returns:

TypeDescription
BooleanReturns if it should be overriding scale

Example:

myAnim:getOverrideScale()

Misc

getName()

Returns this animation's name

getName()

Returns:

TypeDescription
StringReturns the animation's name

Example:

myAnim:getName()

newCode()

Adds a string to run in a determinant time

If there's already code to run at that time, it is overwritten

newCode(time, code)

Parameters:

NameTypeDescriptionDefault
timeNumberThe time in seconds to add the code to0
codeStringThe code to run at that timeRequired

Returns:

TypeDescription
AnimationReturns the given animation for chaining

Example:

myAnim:newCode(0.5, "log('Hello World')")

Fields

name

This animation's name

Example:

myAnim.name