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. (correct me if iām wrong).
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