For the complete documentation index, see llms.txt. This page is also available as Markdown.

TweenService

TweenService : Instance

Overview

TweenService allows the creation of tween Objects for animation effects

The functionality of a tween depends on the properties set during its creation.

DataType
Usage Example

CFrame

CFrame

Vector3

Position, Orientation, Size

Color3

Color

number

Transparency

bool

CanCollide

UDim2

Position, Size

UDim

Padding

Vector2

ImageRectOffset

Rect

SliceCenter

Important Notes

  • Only the types in the table above can be tweened. If a property of another type, such as Enum, string, or Instance, is specified, an error occurs when Create() is called.

  • If a new tween targeting the same property as a tween playing on the same instance is played, the existing tween is canceled entirely and its Completed event fires with the Cancelled state.

Properties

Methods

Create

Creates a new tween animation for a specific instance. Arguments passed to the Create() method define the instance to apply the tween to, the TweenInfo defining the tween's behavior, and the properties apply tween to.

Parameters

Instance Instance

The target tween Object

TweenInfo TweenInfo

An Object that sets the duration, EasingStyle, and repeat count of tween

Value PropertyTable

A dictionary defining the properties and target values to apply tween to

Return

Instance

The created tween Object

Code Samples

GetValue

A method that calculates and returns the value obtained by applying EasingStyle and EasingDirection to a progress (alpha) between 0 and 1.

It can be used when you only need the value of an easing curve without creating a Tween. alpha is limited to between 0 and 1.

Parameters

number Alpha

The progress between 0 and 1.

Enum.EasingStyle EasingStyle

The easing style to apply.

Enum.EasingDirection EasingDirection

The easing direction to apply.

Return

number

The value with easing applied.

Code Samples

SmoothDamp

A method that calculates and returns the next value and velocity so that the current value smoothly follows the target value.

By calling it every frame and passing the returned velocity back into the next call, you can create movement that follows naturally even when the target value keeps changing. The number, Vector2, Vector3, and CFrame types can be used, and current, target, and velocity must be of the same type.

Parameters

Value Current

The current value.

Value Target

The target value.

Value CurrentVelocity

The current velocity. On the first call, pass a value equivalent to 0.

number SmoothTime

The approximate time (in seconds) it takes to reach the target.

number MaxSpeed

The maximum speed.

number DeltaTime

The time (in seconds) elapsed since the previous call.

Return

Tuple

The next value and the velocity to pass to the next call.

Code Samples

Events

See also

Tween

Last updated