You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to save a UDim2 Value and then load it
What is the issue? Include screenshots / videos if possible!
The saving works but i cannot seem to unpack it correctly it gives nil
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Value = UDim2.new(0.5, 0, -1.5, 0)
local Table = {Value}
local New = unpack(Table)
print(New) -- this prints out {0.5, 0}, {-1.5, 0}
local UdimTest = UDim2.new(New)
print(UdimTest) -- but here its nil
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
UDim2 is not serialisable so you need to save the individual values. In this case the problem is that the table you want to later unpack consists of the UDim2 itself not its values. You just need to change the composition of your table to get this working.
local Value = UDim2.fromScale(0.5, -1.5)
local Table = {Value.X.Scale, Value.Y.Scale}
local UDimTest = UDim2.fromScale(table.unpack(Table))
print(UDimTest)
Essentially what happened with your original code was that you were trying to create a UDim2 with a UDim2, or something to that extent. You put a UDim2 into a table and then unpacked it, thus getting back that same UDim2, not its X and Y values.
I don’t know how arbitrary you wanted this so I just changed it to use fromScale. Additionally its important that you unpack in the UDim2 constructor because table.unpack returns a tuple so assigning only one variable will only catch the first value out of the unpack.