Hey everyone,
As a Roblox developer, it is currently difficult to apply TweenInfo
settings conveniently. It is mandatory to include the arguments right then and there which means you cannot mutate them afterwards. With RaycastParams
, for example, you can mutate the object properties after it has been created:
-- taken from DevHub
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {workspace.Model}
raycastParams.IgnoreWater = true
This is very convenient as you do not need to remember the order of parameters in the constructor and default values take precedence unless changed. With TweenInfo
, I propose that we should have this ability on top of traditionally inputting arguments. Something like:
-- doing this right now errors with "X cannot be assigned to"
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear) -- arguments here still allowed
tweenInfo.Reverses = true
tweenInfo.DelayTime = 1
Reverses
and DelayTime
are the last parameters. All parameters have default values, but if I want to modify those last parameters, I’d have to give the values of the already defaulted parameters to get there, like so:
-- all except the last two are default values
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
0,
true, -- reverses: NOT default
1 -- delay time: NOT default
)
This is an absolute bloat and not everyone may remember the order of parameters (I often get mixed up with EasingStyle
and EasingDirection
, which forces me an unnecessary DevHub dive).
If this were added, it’d improve my development experience because I can easily modify TweenInfo
parameters without having to go through the hassle of providing a huge tuple all the time. The current behavior will stay, of course, for convenience (in certain other cases) and compatibility. Plus, since there are default values for these parameters already in place, this new design fits perfectly with it.
Thank you.