Making custom player list

Hello, Developers recently I started making a custom player list system I made UI’s but I don’t have any clue how to script it could you provide some example scripts?

I know I need to use PlayerAdded and PlayerRemoving but the bit I am confused about is how to make leaderstats.

Something like this image
to something like this image

5 Likes

Assuming that leaderstats will always exist for each player, I would probably connect a :WaitForChild("leaderstats") to each player when they join, and when it pops up, create the appropriate frames for it and everything from the values under leaderstats.

Maybe something like this in a local script near a gui somewhere:

local Players = game:GetService("Players")

local PlayerRoster = --set up player roster legend and etc.

local function CreatePlayerEntry(player)
	local entry = -- create frame clone, fill in player info, etc.,
	-- but don't place it in the frame until all info is filled
	return entry
end

local function CreateStats(player)
	local leaderstats = player:WaitForChild("leaderstats")
	local entry = CreatePlayerEntry(player) -- :IsA("GuiObject")

	for _,value in ipairs(leaderstats:GetChildren()) do
		value.Changed:Connect(function(newValue)
			entry[value.Name].Text = newValue
		end)
		entry[value.Name].Text = value.Value
	end
	
	entry.Parent = PlayerRoster
end

Players.PlayerAdded:Connect(CreateStats)

for _,player in ipairs(Players:GetPlayers()) do
	CreateStats(player)
end

Players.PlayerRemoving:Connect(function(player)
	local playerEntry = --find the entry in the player roster using the player
	playerEntry:Destroy()
end)
4 Likes

To add on to this post, you would want to make sure you update the text when the leaderstats value is changed.

	for _,value in ipairs(leaderstats:GetChildren()) do
		entry[value.Name].Text = value.Value
		value:GetPropertyChangedSignal("Value"):Connect(function()
        	entry[value.Name].Text = value.Value
		end)
	end

Also, make sure you remove the frame when the player leaves. :slight_smile:

3 Likes

Ok, so you don’t understand me the problem that I am having is setting the size and position of the main frame not changing and setting the stats value.

This video may come in handy, I do suggest watching it as the position math is explained quite well. How to Make a Player List with Tweening | Roblox Scripting Tutorial - YouTube

note as of 12/31/22 you should be using UiListLayouts & scrollingframes for this kind of thing, instead of the video above for positioning. you can still use a chunk of the video for information and a general idea on how to get it done

1 Like

For a player list, you want to make a Frame for them all to stay in. If you want them to be lined up under each other, insert something called a UIListLayout so that all the names are listed under each other (you can set he transparency to 1 so that it looks smoother, as well as make it into a scrolling frame). Play around with the size in the frame you’ve made and then set it to what you like. After you found your desired frame sizes, have that in a separate storage name tag cloned into the frame every time a player joins. The UIListLayout will automatically put it into the list under the last person that joined.

Edit:
@goldenstein64 Posted a script you can use to load their actual data into the list from there. If you have any more questions, just ask or tick my reply so people will know it’s solved

Also I found your channel, it’s nice keep working at it

4 Likes