Table to UDim2 [ HOW ]

How to make function that use table as variable and return as UDim2
So I give an example :

type tbl = {}
function Position(Object, Property : tbl)
	Object.Position = UDim2.new(Property)
end

Position(Frame, {0.3, 0.2, 0.5, 0.2})
function Position(Object, Property : tbl)
	Object.Position = UDim2.new(Property[1],Property[2],Property[3],Property[4])
end

Just index the numbers in order of the table

Well it need like that? We can’t make without have to index one by one?

Alternatively you can just use table.unpack()

function Position(Object, Property : tbl)
	Object.Position = UDim2.new(table.unpack(Property))
end
1 Like

Or to check if someone type more than 4 index in Property it will return print what, but if they index == 4 it will result like that

Is it gonna include the comma tho?

Yes, it returns the table as tuple’s

Oh yeah how to check if inside the Property table if a person only put less than four or more than four values it will print “NO”

function Position(Object, Property : tbl)
    assert(#Property == 4, "Udim2 Properties must contain 4 number values")
	Object.Position = UDim2.new(table.unpack(Property))
end

Get length of property table then error accordingly