States

The following are properties representing the tween's state:

  • Playing: boolean

  • Repetitions: number

  • Reverse: boolean

  • : number

Example:

Script1
local tween = Tween(workspace.Part, {Transparency = 1}, {Time = 2, Repetitions = 5, Reverses = true})
shared.MyTween = tween -- Share the tween with other scripts.
tween:Start()
Script2
task.wait(5)
if shared.MyTween.Playing then
	print("Tween is still playing, wow!")
	-- Let's print some information about the progress!
	print("Tween is going "..(if shared.MyTween.Reverses then " in reverse" else "forward").."!")
	print("Tween has done "..shared.MyTween.Repetitions.." repetitions!")
	print("Tween is exactly "..shared.MyTween.Alpha*100.."% done with the current repetition.") -- Alpha is in the range 0-1, so we multiply by 100 to get the percentage.
else
	print("Tween is not playing anymore :(")
end

Note that this is a rather useless example, simply to give an idea of what it does. There are actually good use cases for this of course!

Last updated