The question I’m asking is, which is more efficient?
Though UIObject:Tween() is easier to make, I still use TweenService:Create(UIObject) as a habit, and I’m wondering if any of these have a difference perfomance-wise.
For those who don’t know exactly what I’m talking about,
--UIObject:Tween() example:
local Frame = Instance.new("Frame")
Frame:TweenPosition(UDim2.new(1,0,1,0), Enum.EasingStyle.Linear, Enum.EasingDirection.In, 1)
--TweenService:Create(UIObject) example:
local TweenService = game:GetService("TweenService")
local Frame = Instance.new("Frame")
local TI = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local TweenTrack = TweenService:Create(Frame, TI, {Position = UDim2.new(1,0,1,0)})
TweenTrack:Play()
I personally like using the GuiObject methods, I don’t know why, I might find it slightly easier without having to write an extra long line including TweenInfo.
Although, there are some benefits of using TweenService over the GuiObject methods, one being TweenService will tween the GuiObject even if its parent is set to nil, while the GuiObject method would throw an error.
I am not sure if you fully understand what performance is. This is more of an ergonomics thing rather than performance. I don’t think you should worry about performance here. Performance is overrated. I personally use the former since there is no built-in tweening methods for other Instances, only GuiObjects. I find this inconsistent so I just use tween service. And if you ever find yourself needing to tween another property that isn’t size or position (like color), you’re out of luck looking for a built-in method.
UIObject:Tween() is more efficient, but it’s an old method and can only change size and position. TweenService:Create() is newer and can let you modify any numerical property you want, but it has the overhead of requiring you to make a Tween object and TweenInfo object.
Like incapaz said, performance don’t matter much here. I always use TweenService now because it’s easier if I want to change something or add new properties or callbacks or whatever.