Miliastra Wonderland Lua API

Tween

The type that represents an instance of a Tween which can be used to animate Client Controls. Contains functions for changing the Tween's behavior and playback state.

Tween Playback States:

  • Initial
  • Playing
  • Paused
  • Completed
  • Locked

While in the Playing state, fields being tweened cannot be changed.

Attempting to tween the same field from multiple Tweens on the same Client Control will cause different behaviors depending on the state and behavior that the currently playing Tween is in.

Methods11

function Tween:Complete()

Immediately completes Tween playback, moving the Tween to the Completed state.

  • The OnStepComplete and OnComplete callbacks of the Tween will be called.
function Tween:Kill(complete: boolean)

Destroys the Tween.

Parameters
completeboolean

Whether to immediately complete Tween playback and invoke the OnStepComplete and OnComplete callbacks.

function Tween:Pause()

Pauses Tween playback, moving the Tween to the Paused state.

  • Only takes effect if the Tween is in the Playing state.
  • Manual modifications made to tweened fields while paused will be overriden by the Tween's calculated values upon resuming.
function Tween:Play() -> t Tween

Starts Tween playback, moving the Tween to the Playing state, and returns the current instance.

  • Only takes effect if the Tween is in the Initial state.
  • While in the Playing state, fields being tweened cannot be changed.
Returns
tTween

The current Tween instance.

function Tween:Restart()

Resets the tweened fields to their initial values and begins playback from the start.

  • Only takes effect if the Tween is not in the Initial state.
function Tween:Resume()

Resumes Tween playback, moving the Tween to the Playing state.

  • Only takes effect if the Tween is in the Paused state.
  • Manual modifications made to tweened fields while paused will be overriden by the Tween's calculated values upon resuming.
function Tween:SetEase(easeType: EnumItem.EaseType) -> t Tween

Sets the easing function of the Tween and returns the current instance.

  • Only takes effect if the Tween is in the Initial state.

See:

Parameters
easeTypeEnumItem.EaseType

The easing function to animate fields with.

Returns
tTween

The current Tween instance.

function Tween:SetLoops(loops: number) -> t Tween

Sets the number of times the Tween will complete playback before moving to the Completed state and returns the current instance.

  • The number of loops can only be set if the Tween is in the Initial state.
  • The Tween will always play at least once; a negative value will cause the Tween to loop indefinitely.
Parameters
loopsnumber

The number of times to loop playback.

Returns
tTween

The current Tween instance.

function Tween:SetOnComplete(callback: fun() -> nil) -> t Tween

Sets the OnComplete callback and returns current instance.

  • Callbacks can only be set if the Tween is in the Initial state.
  • The OnComplete callback is called when Tween playback completes.
Parameters
callbackfun() -> nil

The function to call when the Tween completes.

Returns
tTween

The current Tween instance.

function Tween:SetOnStepComplete(callback: fun() -> nil) -> t Tween

Sets the OnStepComplete callback and returns current instance.

  • Callbacks can only be set if the Tween is in the Initial state.
  • The OnStepComplete callback is called when the Tween loops or completes playback.
Parameters
callbackfun() -> nil

The function to call when the Tween loops or completes playback.

Returns
tTween

The current Tween instance.

function Tween:SetRelative(relative: boolean) -> t Tween

Sets how the target values are interpreted during the tween and returns the current instance.

  • The relative tween mode can only be set if the Tween is in the Initial state.

When tweening relatively:

  • Target values are interpreted as being added to the values stored in the Initial state.
  • Only number fields will be applied. Color fields will not take effect.
Parameters
relativeboolean

Whether to interpret target values relative to the values stored in the Initial state.

Returns
tTween

The current Tween instance.