Is there any reason to use Tween variables over just using :Create()

this may seem like a kind of stupid answer but is there a reason to use something like this

local tweenService = game:GetService("TweenService")
local remote = game.ReplicatedStorage.RemoteEvent
local tween = tweenService:Create(script.parent, TweenInfo.new(), {BackgroundTransparency = 0.0})

remote.OnClientEvent:Connect(function()
tween:Play()
end)

over this?

local tweenService = game:GetService("TweenService")
local remote = game.ReplicatedStorage.RemoteEvent

remote.OnClientEvent:Connect(function()
tweenService:Create(script.parent, TweenInfo.new(), {BackgroundTransparency = 0.0}):Play()
end)

Is it like better at performance or is it just a personal preference that some developers use?

(if there are errors in the code thats because i typed them straight into here, they are just examples, not any code im working on for a game or project)

i believe it is preference but making a variable can give you access to :Cancel(), :Pause() or even a function that fires when it ends, etc. :grinning_face: (correct me if i’m wrong).

1 Like

when you use TweenService:Create() you are essentially creating an object with all the information of the tween.

Similar reason you would wanna store any object within a variable is so you can access it later for an example:

local tween = TweenService:Create()
tween:Play() -- play the tween like normal
tween:Destroy() -- maybe if you wanna stop and destroy an existing clean
tween:Pause() -- you can pause and resume the same tween

Doing this is soley dependent one what you are trying to accomplish

2 Likes

can i use the tween:Pause() and the tweeninfo reverses boolean to have a pause without having to use two tweens?

for example:

local tween = tweenService:Create(script.parent, TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.Out, 0, true), {BackgroundTransparency = 0.0})

tween:Play()
task.wait(1)
tween:Pause()
task.wait(5)
tween:Play()

or would there be issues?