How can i count UDim2?

I have a problem with UDim2 counting. When my loop goes 2 times I want to change the button position to 0.2, not 0.1, but I can’t calculate UDim2.
Why?
Script:

for _, pla in pairs(game.Players:GetChildren()) do
		if pla.Name ~= player.Name then
			local button = Instance.new('TextButton')
			button.Parent = script.Parent
			button.Size = UDim2.new(1,0,0.1,0)
			button.Position = UDim2.new(0,0,0.1,0)
			button.Position = UDim2.new(0,0,0.1,0) + UDim2.new(0,0,0.1,0)
			button.Text = pla.Name
			button.TextScaled = true
		end
end

If I understood your issue you want something like this?

local count = 0

for _, pla in pairs(game.Players:GetChildren()) do
		if pla.Name ~= player.Name then
            count += .1
			local button = Instance.new('TextButton')
			button.Parent = script.Parent
			button.Size = UDim2.new(1,0,0.1,0)
			button.Position = UDim2.new(0,0,count,0)
			button.Position = UDim2.new(0,0,0.1,0) + UDim2.new(0,0,0.1,0)
			button.Text = pla.Name
			button.TextScaled = true
		end
end
2 Likes

Something like this. I made it my own.
Thank You :hearts: