Empty
Empty
Empty
TweenService is a service in Roblox that allows you to create smooth animations for GUI elements, parts, and other objects. It is used to interpolate properties of an object from one state to another over a specified duration.
Tween | A tween is an animation that interpolates the properties of an object from a start state to an end state. |
TweenInfo | This defines the parameters of the tween, such as duration, easing style, easing direction, and repetition. |
Easing Styles and Directions | Easing styles define the mathematical function used to interpolate between the start and end values of the tween. Easing directions define how the tween progresses relative to the start and end values. |
Tweenable Objects
Empty
Empty
Empty
Position | Move parts/models to a new location. |
Size | Change the dimensions of parts/models. |
Orientation | Rotate parts/models. |
Transparency | Adjust the transparency level of parts/models. |
Color | Change the color of parts/models. |
Empty
Empty
Empty
Position | Move parts/models to a new location. |
Size | Change the dimensions of parts/models. |
BackgroundColor3 | Change the background color of GUI elements. |
Transparency | Adjust the transparency level of parts/models. |
Empty
Empty
Empty
Brightness | Adjust the brightness of a light source. |
Color | Change the color of parts/models. |
Range | Change the range of a light source. |
Empty
Empty
Empty
CFrame | Move or rotate the camera. |
Empty
Empty
Empty
Volume | Adjust the volume of a sound. |
PlaybackSpeed | Change the playback speed of a sound. |
TweenService Example
Tweening Position
local TweenService = game:GetService("TweenService")
-- Define TweenInfo
local tweenInfo = TweenInfo.new(
2, -- Time (seconds)
Enum.EasingStyle.Quad, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat count (0 means no repeat)
false, -- Reverses (tween goes back and forth)
0 -- Delay time (seconds)
)
local part = script.Parent
part.Position = Vector3.new(0, 2.5, 0)
part.Anchored = true
part.Parent = workspace
-- Define the end state of the properties you want to tween
local goal = {}
goal.Position = Vector3.new(10, 5, 0)
-- Create the tween
local tween = TweenService:Create(part, tweenInfo, goal)
-- Play the tween
tween:Play()
Roblox Studio
Tweening GUI Elements
local TweenService = game:GetService("TweenService")
-- Define TweenInfo
local tweenInfo = TweenInfo.new(
2, -- Time (seconds)
Enum.EasingStyle.Quad, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat count (0 means no repeat)
false, -- Reverses (tween goes back and forth)
0 -- Delay time (seconds)
)
local part = script.Parent
part.Position = Vector3.new(0, 2.5, 0)
part.Anchored = true
part.Parent = workspace
-- Define the end state of the properties you want to tween
local goal = {}
goal.Position = Vector3.new(10, 5, 0)
-- Create the tween
local tween = TweenService:Create(part, tweenInfo, goal)
-- Play the tween
tween:Play()
Roblox Studio
Tweening Light Properties
local TweenService = game:GetService("TweenService")
-- Define TweenInfo
local tweenInfo = TweenInfo.new(
2, -- Time (seconds)
Enum.EasingStyle.Quad, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat count (0 means no repeat)
false, -- Reverses (tween goes back and forth)
0 -- Delay time (seconds)
)
local part = script.Parent
part.Position = Vector3.new(0, 2.5, 0)
part.Anchored = true
part.Parent = workspace
-- Define the end state of the properties you want to tween
local goal = {}
goal.Position = Vector3.new(10, 5, 0)
-- Create the tween
local tween = TweenService:Create(part, tweenInfo, goal)
-- Play the tween
tween:Play()
Roblox Studio
Easing Styles
Empty
Empty
Empty
Linear | Moves at a constant speed from start to end. |
Sine | Uses a sine wave for smooth, periodic motion. |
Back | Overshoots the end value before settling back. |
Quad | Accelerates quickly and then slows down. |
Cubic | Similar to Quad, but with a stronger acceleration and deceleration. |
Quart | Even stronger acceleration and deceleration than Cubic. |
Quint | The strongest acceleration and deceleration. |
Bounce | Mimics a bouncing effect at the end. |
Elastic | Moves past the end value in a spring-like manner. |
Exponential | Starts slowly and accelerates exponentially. |
Empty
Empty
Empty
In | Starts the tween slowly and speeds up towards the end. |
Out | Starts the tween quickly and slows down towards the end. |
InOut | Combines both 'In' and 'Out', starting slowly, speeding up in the middle, and slowing down again towards the end. |