PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Pause

The Pause function halts playback of its Tween. However the progress variables of the tween will not be reset, meaning that when TweenBase/Play is called again the tween will resume playback from the moment it was paused.

If a developer wishes to reset the progress variables of the tween, they should use TweenBase/Cancel.

This means a tween paused half way through its animation will take half of its duration to complete when resumed.

Returns

Return Type Summary

Code Samples


Pausing a Tween

This sample demonstrates how the playback of a tween can be paused and resumed.

A part is instanced in the Workspace and a tween is setup that will move it 50 studs along the X axis. However during playback the tween is briefly paused, then resumed. To further illustrate this the BrickColor of the part changes from red to green whilst it is paused.

local TweenService = game:GetService("TweenService")
 
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.BrickColor = BrickColor.new("Bright green")
part.Parent = game.Workspace
 
local goal = {}
goal.Position = Vector3.new(50, 10, 0)
 
local tweenInfo = TweenInfo.new(10, Enum.EasingStyle.Linear)
 
local tween = TweenService:Create(part, tweenInfo, goal)
 
tween:Play()
 
wait(3)
part.BrickColor = BrickColor.new("Bright red")
tween:Pause()
 
wait(2)
part.BrickColor = BrickColor.new("Bright green")
tween:Play()