Tween

Tween : TweenBase

Overview

The Tween class is a fundamental part of animating properties in game objects, providing a way to interpolate values over time using customizable easing styles and directions. It is widely used for creating smooth transitions and animations in game elements.

Description

The Tween class allows for seamless animations by interpolating properties such as position, color, size, and more over a specified duration. By leveraging the EasingStyle and EasingDirection properties, Tween animations can achieve dynamic motion effects that enhance user experience and interaction in applications.

Properties

TweenInfo

TweenInfo

The TweenInfo property defines the duration, easing style, easing direction, repeat count, reverses, and delay time for the Tween animation. It is essential for customizing the characteristics of the animation.

Code Samples

local TweenService = game:GetService("TweenService")
local Part = workspace:WaitForChild("Part") -- μ΄λ™μ‹œν‚¬ 파트

-- Tween 정보 μ„€μ •
local TweenInfoData = TweenInfo.new(
    5,                        -- 지속 μ‹œκ°„ (초)
    Enum.EasingStyle.Linear,  -- 트윈 μŠ€νƒ€μΌ
    Enum.EasingDirection.Out, -- 트윈 λ°©ν–₯
    0,                        -- 반볡 횟수
    false,                    -- 왕볡 μ—¬λΆ€
    0                         -- λŒ€κΈ° μ‹œκ°„
)

-- 트윈 μœ„μΉ˜ 이동
local TweenGoals = 
{
    Position = Vector3.new(-400, 50, -350)
}

local Tween = TweenService:Create(Part, TweenInfoData, TweenGoals)
Tween:Play()

Methods

Play

The Play method starts or resumes the Tween animation, allowing the object’s properties to transition smoothly toward the defined goals.

Parameters

Return

void

Code Samples

Tween:Play()

Cancel

The Cancel method stops the Tween animation immediately and resets the properties to their initial state.

Parameters

Return

void

Code Samples

Tween:Cancel()

Pause

The Pause method temporarily halts the Tween animation, allowing it to be resumed later without resetting.

Parameters

Return

void

Code Samples

Tween:Pause() -- Pause
wait(2)

Tween:Play()  -- Resume

Events