I’ll get straight to the point: I’m getting an error while using TweenPosition and I have no clue why.
local TweenSettings = {
Enum.EasingDirection.Out,
Enum.EasingStyle.Bounce,
.5,
true
}
TextLabel:TweenPosition( --error is thrown from this line
UDim2.new(1, 2, 3, 4),
unpack(TweenSettings), --if I put in the actual table values and remove the unpack, it works
function() TextLabel.Text="" end --if I don't put in this line, it works
)
With the above code, I get:
Hope someone smarter than me can help me out. Thanks in advance.
That’s a weird way to use unpack and TweenPosition. I personally would avoid using these weird methods in the first place, as TweenService can accomplish what you require better than what these can.
What I assume is happening here is that unpack is returning only one argument based on your usage. Unpack would suggest varargs which is only valid when attached to the end of a function’s parameters. It doesn’t push all the returns like you’d expect it to. This is based on your comment of how unpack is the problem segment and removing it for hard-coded parameter assignment fixes the issue, as well as how the function is being assigned to an incorrect slot.
I get that I can do it using alternative methods, but I’d still like to know why this method doesn’t work.
I’m a table and then unpacking it because I don’t feel like copypasting my tween settings every single time I want to tween something; my main UI handler puts the settings into shared and then all my UI uses these settings, which can be easily changed in one place.
I’ve tested unpack when attempting to determine the problem and it worked as intended, and I’ve also used it in the past without incident. It’s also not just for varargs, it’s designed to work with any table.