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

PlaybackState

TweenBase

PlaybackState

Read only property that shows the current playback Enum/PlaybackState of the Tween. PlaybackState is an Enum type variable with the following possible values.

  • Delayed - The tween is waiting to repeat due to the DelayTime property of the Tween’s DataType/TweenInfo
  • Playing - The tween is playing normally
  • Paused - The tween has been paused
  • Completed - The tween has completed successfully
  • Cancelled - The tween has been cancelled

Code Samples


Tween PlaybackState

In this example a part is rotated by a Tween back and forth several times. The TweenInfo in this case is configured to make the tween repeat twice after the first playback and pause between each playback. A function is connected to when the tween’s PlaybackState changes. When run, this function will fire whenever the tween starts, pauses between playback, and ends.

local TweenService = game:GetService("TweenService")
 
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = game.Workspace
 
local goal = {}
goal.Orientation = Vector3.new(0, 90, 0)
 
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 2, true, 0.5)
 
local tween = TweenService:Create(part, tweenInfo, goal)
 
local function onPlaybackChanged()
	print("Tween status has changed to:", tween.PlaybackState)
end
 
local playbackChanged = tween:GetPropertyChangedSignal("PlaybackState")
playbackChanged:Connect(onPlaybackChanged)
 
tween:Play()