Skip to main content

Tween Service

TweenService is a utility service for creating and managing tweens, allowing smooth interpolation of properties such as numbers, colors, UDim2, and Vector2 over time.

TweenService
Service
Singleton

Constructors

TweenService:Create()
Function

TweenService:Create(object, tweenInfo, goal)

  • Creates a new tween for a given object with specified TweenInfo and goal properties.

Parameters:

  • object

    any

  • The target object whose properties will be tweened.

  • tweenInfo

    TweenInfo

  • A TweenInfo instance specifying duration and easing.

  • goal

    table

  • A table defining target values for properties.

Returns:

  • Tween
    Tween
    • The created tween object.

Tween Object
Object

(Tween):Play()
Method

  • Starts the tween. Once playing, the tween is updated automatically via TweenService:Update.

(Tween):Stop()
Method

  • Stops the tween and removes it from the active tweens list.

(Tween).Completed
Signal

  • Fires when the tween completes.

TweenInfo Object
Object

TweenInfo.new()
Constructor

TweenInfo.new(time, easingStyle)

  • Creates a new TweenInfo object.

Parameters:

  • Time
    number
    • Duration of the tween in seconds. Default is 1.
  • EasingStyle
    function?
    • Easing function. Default is linear.

Internal Functions

TweenService:Update()
Internal

  • Updates all active tweens.

Parameters:

  • dt
    number
    • Delta time for the frame

Do not call this manually.
This method is automatically invoked by UpdateService and is not intended for direct use in user code.

Example

local tweenInfo = TweenInfo.new(1, "linear")
-- Create a new tween
local tween = TweenService:Create(myObject, tweenInfo, { Position = UDim2.new(0, 100, 0, 100) })
-- Start the tween
tween:Play()

-- Wait for the tween to complete
tween.Completed:Connect(function()
print("Tween completed!")
end)