Tweens
Import Weave.Tween from the Weave module.
1 2 | |
Tween values Tween any Weave Value or Computed
local value = Value.new(0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local tweenValue = Tween(value, tweenInfo)
✨ Tween values update automatically ✨
value:set(5)
task.wait(0.5) -- wait half the duration
tweenValue:get() -- 2.5
Tweens follow the value of Weave state using an animation curve.
Usage¶
Call the Tween function with a Weave Value and a TweenInfo
local value = Value.new(0)
local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad)
local animated = Tween(value, tweenInfo)
You can :get() its value at any time.
print(animated:get()) --> 0.26425...
TweenInfo can also be a Weave Value or Computed
local goal = Value.new(0)
local tweenInfo = Value.new(TweenInfo.new(0.5, Enum.EasingStyle.Quad))
local animated = Tween(target, tweenInfo)
Tween can transition any number-based Luau type:
local partPosition = Value.new(Vector3.new())
local mousePosition = Value.new(Vector2.new())
local partColor = Value.new(Color3.new(0, 0, 0))
local framePosition = Value.new(UDim2.new(0.5, 0, 0, 0))
local modelPosition = Value.new(CFrame.new())
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad)
local partTween = Tween(partPosition, tweenInfo)
local mouseTween = Tween(mousePosition, tweenInfo)
local colorTween = Tween(partPosition, tweenInfo)
local frameTween = Tween(framePosition, tweenInfo)
local modelTween = Tween(modelPosition, tweenInfo)
TweenInfo¶
Time¶
The first parameter of TweenInfo is time in seconds.
This specifies how long it will take to animate.

EasingStyle¶
The second parameter of TweenInfo is easing style.
Enum.EasingStyle defines the animation curve.

Easing Direction¶
The third parameter of TweenInfo is EasingDirection.
This can be set to:
Enum.EasingDirection.Outanimates out smoothly.Enum.EasingDirection.Inanimates in smoothly.Enum.EasingDirection.InOutanimates in and out smoothly.

Repeats¶
The fourth parameter of TweenInfo is repeat count.
This can loop the animation a number of times.
Setting the repeat count to a -1 causes it to loop infinitely.

Reversing¶
The fifth parameter of TweenInfo is a reversing option.
When enabled, the animation will return to the starting point.

Delay¶
The sixth and final parameter of TweenInfo is delay.
Increasing this delay adds time before the beginning of the animation curve.

Advanced: Interruption¶
You should avoid interrupting Tweens before they're finished.
Interrupting a tween halfway through leads to abrupt changes in velocity.

Tweens also can't track constantly changing targets very well.

These issues arise because tweens don't 'remember' their previous velocity.
To retain velocity, consider using springs, since they can preserve momentum.