How do i make a list with all current players?

First of all, i am not trying to make a custom player list.

I want to make a UI that has a list of all current playing players (in the server). Something like “Trade” UIs you see in those generic games with all the players in the server you can press a button to trade.

Thanks!

Make a card when the player joins and delete a card when the player leaves.

Depends if you are making this on the server or client. If it is on a board, then I would do as @dmksa123 said, add the player to the board when they join and remove them when they leave.

If you are doing it on the client (for example a trade menu) then you should do the above as well, but also do game.Players:GetChildren() to add all players who already are in the server.

:GetPlayers() would probably be better for this.

It is on the client.

Could you give some more explanation on the creating the card proccess, which is the part i have the most doubt on how to do.

First of all, @dmksa123 I have somehow never seen this function before, thank you for showing me!

Secondly, in order to create a card I would first create it in studio as usual, I would then move it so the script is the parent of it. This will hide the card.

function createCard(player)
	local playerCard = playerCardTemplate:Clone()
	playerCard.Username.Text = player.Name
	-- Set additional values here
	playerCard.TradeButton.MouseButton1Click:Connect(function()
		sendTrade(player)
	end)
	playerCard.Parent = playerCards -- Or wherever you store them
end)
1 Like

Well, what I usually like to do is make a baseframe in the UI that I can then clone and just replace the text of something’s in the clone. So, use that, and the Players.PlayerAdded and Players.PlayerRemovin function

1 Like