Way to make a custom player list

So i want to create a listing similar to Town Of Salem’s(game) player listing. I would make it, if i knew how to make GUI’s that dont merge into other GUI’s. I’m just wondering how you can make a player list that adds a new player without merging?

To disable Roblox’s default leaderboard, you can use the function. SetCoreGUIEnabled()

Once done, read all players using the game.Players:GetPlayers() function and just update the UI on player leaving or joining events.

Thank you but the thing is I don’t have the GUI and i don’t know how to make it.

idk sometimes i just use legos and build it out of that but its really about how you approach it.

hey i found a soluation!

local textlabel = script.Parent.TextLabel


function ChangeText()
	local Table = {}
	for _, v in pairs(game.Players:GetChildren()) do
		table.insert(Table, v.Name)
	end
	textlabel.Text = table.concat(Table," ")
end

while wait(5) do
	print("refreshing!")
	ChangeText()
end

Hello! Although this may work, this is not the best solution to your problem. A script like this would be a better way to achieve this:

local textlabel = script.Parent.TextLabel
local Table = {}

game.Players.PlayerAdded:Connect(function(player) -- detects when a player joins
    table.insert(Table, player.Name) -- inserts player name into table
    textlabel.Text = table.concat(Table," ")
   print("player "..player.Name.." added to table!")
end)

game.Players.PlayerRemoving:Connect(function(player) -- detects when a player leaves
    table.remove(Table, player.Name) -- removes player name from table
    textlabel.Text = table.concat(Table," ")
    print("player "..player.Name.." removed from table!")
end)

This script will only change the table when needed instead of every five seconds. This makes it more accurate and won’t unnecessarily remove and add back any players from the table.

Also, I’m assuming this script is in a gui? (because of the local textlabel = script.Parent.TextLabel) If so, this script will not work and will need to be changed. I’d recommend putting something like this in a server script:

local Table = {}

game.Players.PlayerAdded:Connect(function(player) -- detects when a player joins
    table.insert(Table, player.Name) -- inserts player name into table
    for i, player in pairs(game.Players:GetPlayers()) do
        -- goes through all players, changing all players' textlabel text to the players
        player.PlayerGui.YourUI.TextLabel.Text = table.concat(Table," ")
    end
    print("player "..player.Name.." added to table!")
end)

game.Players.PlayerRemoving:Connect(function(player) -- detects when a player leaves
    table.remove(Table, player.Name) -- removes player name from table
    for i, player in pairs(game.Players:GetPlayers()) do
        -- goes through all players, changing all players' textlabel text to the players
        player.PlayerGui.YourUI.TextLabel.Text = table.concat(Table," ")
    end
    print("player "..player.Name.." removed from table!")
end)

Sorry if that code is formatted badly, my browser uses tab as a shortcut for the search bar so I had to use spaces instead. :angst:

Let me know if this works for you, hope this helps! :wink:

1 Like