Services
TweenService
Animates supported Instance properties over time using easing.
Accessing TweenService
Luau
local TweenService = game:GetService("TweenService")GetValue
TweenService:GetValue(alpha, easingStyle?, easingDirection?)| Name | Type | Description |
|---|---|---|
alpha | number | Input progress. Values are clamped to the 0 through 1 range. |
easingStyle | Enum.EasingStyle? | Easing curve. Defaults to Quad. |
easingDirection | Enum.EasingDirection? | Easing direction. Defaults to Out. |
return | number | Eased progress value for the selected curve and direction. |
Luau
local TweenService = game:GetService("TweenService")
local eased = TweenService:GetValue(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
print(eased)Create
TweenService:Create(instance, tweenInfo, goals)| Name | Type | Description |
|---|---|---|
instance | Instance | Instance to animate. |
tweenInfo | TweenInfo | Duration, easing, repeat, reverse and delay settings. |
goals | table | Property names mapped to target values. |
return | Tween | Tween object controlled with Play(), Pause(), Cancel() and Destroy(). |
TweenInfo
TweenInfo.new(time, easingStyle?, easingDirection?, repeatCount?, reverses?, delayTime?)| Name | Type | Description |
|---|---|---|
Time | number | Duration of one direction of the tween. |
EasingStyle | Enum.EasingStyle | Linear, Quad, Cubic, Quart, Sine, Back or Bounce. |
EasingDirection | Enum.EasingDirection | In, Out or InOut. |
RepeatCount | integer | Additional cycles. A negative value repeats indefinitely. |
Reverses | boolean | Runs back toward the starting values after reaching the goals. |
DelayTime | number | Delay before each cycle starts. |
Example: Move A Part
Luau
local TweenService = game:GetService("TweenService")
local part = workspace:FindFirstChild("Part")
if part then
local tween = TweenService:Create(
part,
TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut),
{ Position = part.Position + Vector3.new(0, 8, 0) }
)
tween:Play()
endNumbers, Vector values and CFrames interpolate over time. Other writable values are assigned when the tween reaches the end.
Tween members
| Name | Type | Description |
|---|---|---|
Play() | method | Starts a new run or resumes a paused tween. |
Pause() | method | Pauses an active tween. |
Cancel() | method | Stops an active tween and marks it Cancelled. |
Destroy() | method | Cancels the tween. |
Completed | signal | Fires with the final playback state when the tween completes or is cancelled. |
PlaybackState | Enum.PlaybackState | Current tween state. |