I am trying to list about 10 Guis in a single line, sort of like a drop down menu, except in this case they don't disappear. It worked, but not exactly how it suppose to
ChallengeList is a table that store all the Guis that I added, if the table is empty than the first gui position would be 0, 3, 0, 3 and then it add up 23 from the last Gui inserted in the table ( 3 + 23 = 26)
There no errors, but what happening is that the first two Guis position become 0, 3, 0, 3 and the third one become 26 and so on. Anyone know exactly how I can solve this problem?
Gui.Position = (ChallengeList[#ChallengeList-1] ~= nil and ChallengeList[#ChallengeList-1].Position + UDim2.new(0, 0, 0, 23)) or (UDim2.new(0, 3, 0, 3)
If you have a list, then the n
th element will just be at 3 + 23 * (n-1)
y:
for i = 1, #list do -- label is your gui object label.Position = UDim2.new(0, 0, 0, (i - 1) * 23 + 3) end
Alternatively, the first one is placed somewhere and the next is based on the previous:
local previous for i = 1, #list do -- label is your gui object if previous then label.Position = previous.Position + UDim2.new(0, 0, 0, 23) else label.Position = UDim2.new(0, 0, 0, 3) end previous = label end
The first one seems much simpler.