Tween
Type
Tween controls a running property animation from Tween.Play or Tween.Create; see Tween for tweenable types and options.
Finished
Event
Finished: Signal<TweenEndReason>
Finished fires once with a TweenEndReason when the tween reaches its final value, is overridden on the same property, or ends because its entity was destroyed or lost the tweened component. Kill does not fire Finished.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 0.2)
tween.Finished:Connect(function()
print("faded") -- prints faded
self:Destroy()
end)
Pause
Method
Pause freezes the tween at its current elapsed time and value.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 0.4)
tween:Pause()
print(tween:IsRunning()) -- prints false
Play
Method
Play starts or resumes a paused tween from its current position.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 0.4)
tween:Pause()
tween:Play()
print(tween:IsRunning()) -- prints true
Resume
Method
Resume continues a paused tween from where it stopped.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 0.4)
tween:Pause()
tween:Resume()
print(tween:IsRunning()) -- prints true
Kill
Method
Kill stops the tween at its current value without firing Finished, leaving threads in Finished:Wait() suspended.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 1)
task.wait(0.2)
tween:Kill()
print(tween:IsValid()) -- prints false
IsRunning
Method
IsRunning returns true while advancing or waiting out a delay, and false when paused or ended.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 0.2)
print(tween:IsRunning()) -- prints true
IsValid
Method
IsValid returns true until the tween reaches its final value, is overridden, is killed, or ends because its entity was destroyed or lost the tweened component.
Example
-- Server script in a part.
local tween = Tween.Play(self, Component.Color, Color.Transparent, 0.2)
print(tween:IsValid()) -- prints true
task.wait(0.3)
print(tween:IsValid()) -- prints false