Jeah so I got a Frame and I want to display every Player who is in game with a button. So if there are 2 players in the game it will display 2 buttons with each name of the player. Everything works but they stay in the same position somehow. I want them to go down ( if you know what i mean). Like, they are in the same position but I want one to be in 0,0,0,0 and the next one to be in 0,0,0,5 and the next one in 0,0,0,10 . . .
local gui = script.parent.Parent
local open = gui:WaitForChild("Open")
local frame = gui:WaitForChild("Frame")
local holster = frame:WaitForChild("Holster")
local spectate = frame:WaitForChild("Spectate")
local sponsor = frame:WaitForChild("Sponsor")
local shop = frame:WaitForChild("Shop")
local premium = frame:WaitForChild("Premium")
local template = holster:WaitForChild("template")
local playersintable = {}
local fieldSize = template.Size
local fieldBorder = {x = 0, y = 5}
spectate.MouseButton1Click:connect(function()
print("clicked")
createplayers()
end)
function createplayers()
for i, players in pairs(game.Players:GetPlayers()) do
table.insert(playersintable,players.Name)
end
local toShow = #playersintable
local totalX = (toShow*fieldSize.X.Offset)+((toShow+1)*fieldBorder.x)
local totalY = fieldSize.Y.Offset + (2*fieldBorder.y)
for i = 1, #playersintable do
print(#playersintable)
local value = playersintable[i]
local clone = template:Clone()
clone.Parent = holster
clone.Text = playersintable[i]
clone.Name = playersintable[i]
clone.Visible = true
clone.Position = UDim2.new(0, (i-1)*(fieldSize.X.Offset)+(fieldBorder.x*i), 0, fieldBorder.y)
end
template:Destroy()
end

1 comment
there is something called a UIlistLayout that should do exactly what you want, so you just have to loop over the player table (game.Players:GetPlayers()) and make a button for each of them (make sure to delete old ones though when you refresh the list)