I am trying to make text labels move down when they get added and move up when they are sold but without making the on at the top go to far, here are my codes i tried doing:
When adding to inventory:
for i,j in pairs(inv:GetChildren()) do if j.ClassName == "TextLabel" then j.Position = UDim2.new(0, 0,0, (50 * #inv:GetChildren())) end end
When being sold and deleted from inventory:
for i,v in pairs(inv:GetChildren()) do if v.ClassName == "TextLabel" then v.Position = UDim2.new(0, 0,0, (50 * #inv:GetChildren())) end end
I suggest just repositioning them each time. I've had problems where removing or adding them will cause problems (spaces) if both happen at the same time. Also, if you wanted to animate (tween) them, it works better when there's a set position.
local y = 50 local function repos() local pos = 0 for i,v in pairs(inv:GetChildren()) do -- Retain Scale and Offset on the X axis if there was any when you first created them. v.Position = UDim2.new(v.Position.X.Scale,v.Position.X.Offset,0,pos) pos = pos + y -- + padding (y-spacing) if there is any. end end