Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why don't the text labels move up if I have Position+UDim2.new?

Asked by 10 years ago

I want a Textabel to be created and be sorted like a list(by going up one everytime),but it won't do that.All the TextLabels just have the same position

names = {"Bob","Tod","Jake","Dude","Wut" }--The names
for i,v in pairs (names) do
print(v)
h = Instance.new("TextLabel",script.Parent)
h. Text = v
h.Name = v
h.Size = UDim2.new(0,100,0,100)
wait(1)
h.Position = h.Position+UDim2.new(0,0,1,0)--For each name move up one
end
0
Oops, I mean't to put for each name move up one. kevinnight45 550 — 10y
0
You are able to edit your question, so you don't have to point out errors in the comments. :P adark 5487 — 10y

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

You have to manually add or subtract each component individually. Unlike Vector3, UDim2 does not support component math like that.

Change line 9 in that block to this:

h.Position = UDim2.new(h.Position.X.Scale, h.Position.X.Offset + 1, h.Position.Y.Scale, h.Position.Y.Offset)
0
How can I manually add and subtract it? kevinnight45 550 — 10y
Ad

Answer this question