I want to make it so that when a player leaves the game my custom player list will update and make a new list updating all the button positions to the top most available button slot. This is my script:

local Frame=script.Parent
local Button=Frame.Button
local Players=game:GetService("Players")
local function Add(Player)
local ButtonNumber=Frame.Buttons:GetChildren()
local ButtonC=Button:Clone()
ButtonC.Name=Player.Name
ButtonC.Text=Player.Name
ButtonC.Parent=Frame.Buttons
local Y=0.05*(#ButtonNumber)
ButtonC.Position=UDim2.new(0,10,Y,0)
end
local function Update()
for I,V in pairs(Players:GetPlayers())do
Add(V)
end
Players.PlayerAdded:Connect(function(Player)
Add(Player)
end)
Players.PlayerRemoving:Connect(function(Player)
Frame.Buttons[Player.Name]:Destroy()
end)

There is a folder called buttons and a default button that gets cloned into the folder inside the frame.

8 comments

0

At :Destroy() why don’t u do udim2.new

0

Because Frame.Buttons[Player.Name] is the player being removed

0

Imagine button name is the player so that’s what ur removing so instead of destroy udim2.nee

0

I know I can move the buttons when a player leaves, but I'm asking if there is a way to update all the button's positions to form a new new list.

0

Line 11 try UDim1

0

Also I do want to remove that button, Please stop focusing on it there is nothing wrong with it.

0

Why do UDim1?

0

Get the children in a list then have a number in the list for the position. I dont have time to write out all the code right now but basically what I mean is lets say the list is stored in a variable b then b[1].Position.