[TweenService] Tween does not run if object is not in the game tree

Reproduction:

wait(1)
print("START")
local TweenService = game:GetService("TweenService")
local v = Instance.new("IntValue")
v.Changed:Connect(print)
local t = TweenService:Create(v, TweenInfo.new(1, Enum.EasingStyle.Linear), {Value = 3})
t.Completed:Connect(function() print("FINISH") end)
t:Play()

Expectation:

START
1
2
3
FINISH

Reality:

START
3 Likes

What’s the use case for tweening something outside of the data model?

1 Like

A use case is me rigorously testing TweenService without the overhead of having objects in the game tree.

But really, it’s just unexpected. For objects outside the game tree, properties are still settable, events still fire, functions are still callable, but tweens do not run.

Also, if you put an object in the game tree, start tweening, then immediately remove the object, the tween continues just fine.

wait(1)
local TweenService = game:GetService("TweenService")
local v = Instance.new("IntValue",workspace)
v.Changed:Connect(function(value) print(value, v.Parent) end)
local t = TweenService:Create(v, TweenInfo.new(1, Enum.EasingStyle.Linear), {Value = 3})
t.Completed:Connect(function() print("FINISH", v.Parent) end)
print("START", v.Parent)
t:Play()
v.Parent = nil

--> START Workspace
--> 1 nil
--> 2 nil
--> 3 nil
--> FINISH nil

This demonstrates that being a descendant of the game tree is not actually required in order for an object to tween, so why is it even a thing in the first place?

5 Likes

I’ll look into this. Thanks for the report!

Fix for this is live

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.