Springs
Import Weave.Tween from the Weave module.
1 2 | |
Spring values Spring any Weave Value or Computed
local value = Value.new(0)
local speed = 25
local damping = 0.5
local springValue = Spring(target, speed, damping)
✨ Spring values update automatically ✨
value:set(5)
task.wait(0.5)
springValue:get() -- 1.86
Springs use a physical spring simulation.
Usage¶
Call the Spring function with a Weave value to move towards:
local goal = Value.new(0)
local animated = Spring(target)
:get() its value at any time.
print(animated:get()) --> 0.26425...
Provide speed and damping values to define how the spring moves.
local target = Value.new(0)
local speed = 25
local damping = 0.5
local springValue = Spring(target, speed, damping)
Spring 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 speed = 25
local damping = 0.5
local partTween = Spring(partPosition, speed, damping)
local mouseTween = Spring(mousePosition, speed, damping)
local colorTween = Spring(partPosition, speed, damping)
local frameTween = Spring(framePosition, speed, damping)
local modelTween = Spring(modelPosition, speed, damping)
Speed¶
The speed defines how fast the spring to moves.
Doubling the speed makes it move twice as fast.

Damping¶
The damping defines the friction of the spring.
This defines how quickly or smoothly it reaches a stop.

Advanced: Spring Mechanics¶
Zero damping¶
Zero Damping means no friction, so the spring moves up and down forever.

Underdamping¶
Underdamping applies some friction, so the spring slows down and eventually stops.

Critical damping¶
Critical Damping is just the right amount of friction to stop quickly without extra movement.

Overdamping¶
Overdamping adds lots of friction, making the spring move slowly, like it’s in honey.

Interruption¶
Springs do not share the same interruption problems as tweens. When the goal changes, springs are guaranteed to preserve both position and velocity, reducing jank:

This also means springs are suitable for following rapidly changing values:
