-- Step 1: Import the TweenService
local TweenService = game:GetService("TweenService")
-- Step 2: Create a new TweenInfo object
local tweenInfo = TweenInfo.new(
-- Duration of the tween in seconds
1,
-- Easing style (e.g., Linear, Quad, etc.)
Enum.EasingStyle.Linear,
-- Easing direction (e.g., In, Out, InOut)
Enum.EasingDirection.Out,
-- Number of times to repeat the tween (use math.huge for infinite)
0,
-- Whether to reverse the tween after completing one cycle
false,
-- Delay before starting the tween in seconds
0
)
-- Step 3: Define the properties you want to tween
local properties = {
Position = UDim2.new(1, 0, 0, 0), -- Example: Move to the right
-- Additional properties can be added, such as Size, Rotation, Transparency, etc.
}
-- Step 4: Create a new Tween
local tween = TweenService:Create(
-- Instance to tween (e.g., a GUI object)
script.Parent, -- Replace with the actual object you want to tween
-- TweenInfo object created in Step 2
tweenInfo,
-- Properties to tween and their target values
properties
)
-- Step 5: Define what happens when the tween completes
local function onComplete()
print("Tween completed!")
end
-- Step 6: Connect the onComplete function to the Completed event
tween.Completed:Connect(onComplete)
-- Step 7: Play the tween
tween:Play()