Animation
A Blockbench animation
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
Example:
myAnim:play()
stop()
Gets the animation's priority
Example:
myAnim:stop()
pause()
Pause the animation's playback
Example:
myAnim:pause()
restart()
Restarts the animation
Plays the animation if it was stopped
This behaviour can also be reproduced by stopping then playing the animation
Example:
myAnim:restart()
setPlaying(bool)
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
Example:
myAnim:setPlaying(player:getPose() == "CROUCHING")
isPlaying()
Get if the animation is playing
Example:
myAnim:isPlaying()
isStopped()
Get if the animation is stopped
Example:
myAnim:isStopped()
isPaused()
Gets if the animation is paused
Example:
myAnim:isPaused()
getPlayState()
Get the animation's playback state
These will either be PLAYING
, STOPPED
, or PAUSED
Example:
myAnim:getPlayState() == "PLAYING"
Timing
setLength(number)
Gets the animation's length
Example:
myAnim:setLength(1)
getLength()
Gets the animation's length
Example:
myAnim:getLength()
setPriority(number)
Sets the animation's priority
Instead of blending, low priority animations are overridden by high priority ones
Default priority is 0
Example:
myAnim:setPriority(1)
getPriority()
Gets the animation's priority
Example:
myAnim:getPriority()
setOffset(number)
Sets how much time to skip for the animation
The time is skipped on every loop
Example:
myAnim:setOffset(1)
getOffset()
Gets the animation's offset time
Example:
myAnim:getOffset()
setTime(number)
Get the animation's playback current time Example:
myAnim:setTime(1)
getTime()
Get the animation's playback current time Example:
myAnim:getTime()
setLoop(bool)
Sets the animation's loop mode
Example:
myAnim:setLoop(true)
getLoop()
Gets the animation's loop mode Example:
myAnim:getLoop()
setBlend(number)
Sets the animation's keyframe blend factor
Example:
myAnim:setBlend(.5)
getBlend()
Gets the animation's keyframe blend factor
Example:
myAnim:getBlend()
setStartDelay(number)
Set how much time to wait before this animation is initialized
Note that while it is waiting, the animation is considered being played
Example:
myAnim:setStartDelay(1)
getStartDelay()
Gets the animation's start delay
Example:
myAnim:getStartDelay()
setLoopDelay(number)
Set how much time to wait in between the loops of this animation
Example:
myAnim:setLoopDelay(1)
getLoopDelay()
Gets the animation's loop delay
Example:
myAnim:getLoopDelay()
setSpeed(number)
Sets the animation's playback speed
Negative numbers can be used for an inverted animation
Example:
myAnim:setSpeed(2)
getSpeed()
Gets the animation's speed
Example:
myAnim:getSpeed()
Overriding
setOverride(bool)
Set if this animation should override all of its parts vanilla transforms
Equivalent of calling "overrideRot", "overridePos" and "overrideScale" altogether
Example:
myAnim:setOverride()
setOverrideRot(bool)
Set if this animation should override its parts vanilla rotation
Example:
myAnim:setOverrideRot(true)
getOverrideRot()
Gets if this animation should override its parts vanilla rotation
Example:
myAnim:getOverrideRot()
setOverridePos(bool)
Set if this animation should override its parts vanilla position
Example:
myAnim:setOverridePos(true)
getOverridePos()
Gets if this animation should override its parts vanilla position
Example:
myAnim:getOverridePos()
setOverrideScale(bool)
Set if this animation should override its parts vanilla scale
Example:
myAnim:setOverrideScale(true)
getOverrideScale()
Gets if this animation should override its parts vanilla scale
Example:
myAnim:getOverrideScale()
Misc
getName()
Returns this animation's name
Example:
myAnim:getName()
newCode(number,string)
Adds a string to run in a determinant time
If theres already code to run at that time, it is overridden
Example:
myAnim:newCode(1, "log('hi')")