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

How would I make my custom player list move when a player leaves the game?

Asked by
Narunzo 172
5 years ago
Edited 5 years ago

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.

0
At :Destroy() why don’t u do udim2.new HappyTimIsHim 652 — 5y
0
Because Frame.Buttons[Player.Name] is the player being removed Narunzo 172 — 5y
0
Imagine button name is the player so that’s what ur removing so instead of destroy udim2.nee HappyTimIsHim 652 — 5y
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. Narunzo 172 — 5y
View all comments (4 more)
0
Line 11 try UDim1 xb8y -11 — 5y
0
Also I do want to remove that button, Please stop focusing on it there is nothing wrong with it. Narunzo 172 — 5y
0
Why do UDim1? Narunzo 172 — 5y
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. TiredMelon 405 — 5y

Answer this question