I’m trying to develop a custom playerlist, I am able to make the player list with just players / values, though I cannot figure out how I would add teams and then make sure the player name gets put under the team, I’ve tried using UIListLayout but that just adds them in order. Any recommendations? Thanks.
I think you can do that with the teams service
Um, he means a custom one not made by Roblox
I have not tried this but i can advise you that do not just code and expect a custom team list to pop up outta nowhere. So, my conclusion is that you have to make one yourself.
Note: This is just inference
I recommend utilizing GuiObject.LayoutOrder and a UIListLayout object, I start off by running through the teams and giving them a layout order which is equal to the number of children currently in the player list frame.
for _, team in ipairs(Teams:GetTeam()) do
local frame = template:Clone()
frame.Name = team.Name
-- properties
frame.LayoutOrder = #playerList:GetChildren()
end
I then add all the player frames and make their layout order equal to their team’s layout order plus one and add to the layout order of all frames which are higher than the player’s frame by one. You must also listen for when players join or leave the game and when they switch teams. If they leave the game you need to decrease all frames with a higher layout order by one and if they switch teams you need to re-position their frame. Here is a small sample:
for _, player in ipairs(Players:GetPlayers()) do
local frame = template:Clone()
frame.Name = player.Name
-- properties
frame.LayoutOrder = playerList[player.Team.Name].LayoutOrder + 1
for _, object in ipairs(playerList:GetChildren()) do
if object:IsA("Frame") and object.LayoutOrder >= frame.LayoutOrder and object ~= frame then
object.LayoutOrder = object.LayoutOrder + 1
end
end
player:GetPropertyChangedSignal("Team"):Connect(function()
-- handle team change
end
end
I see, I didn’t look into LayoutOrder, thanks for that! This is exeactly what I was looking for. Much appreciated!