Im trying to make a gui that creates buttons for each of its children. But I am puzzled because im trying to figure out a way to create buttons but after a certain row the y offset moves down and x offset resets. Any ideas?
The y formula works perfectly, but I have no ideas on how to make x return to one.
heres part of the script:
for i=1, (#units) do
local z = Instance.new("TextButton",SelectionFrame)-- Dont worry about this
z.Name = units[i].Name -- or this
decode = Utils.DecodeJSON(units[i].Value) -- or this
z.Text = decode[3] -- or this
z.Size = UDim2.new(0, 32, 0, 32) -- or this
newYPos = i <= 16 and 2 or math.floor(i/16)*(34)
newXPos = i == 1 and 2 or 2+(34*((i/math.ceil(i/16))-(i <= 16 and 1 or 0)))
print(newXPos, math.ceil(i/16), i/math.ceil(i/16),i)
z.Position = UDim2.new(0, newXPos, 0, newYPos )
end |