How to make a leaderboard

Hi so I’m trying to make a leaderboard thing after the game, it shows the players username, place, KO(points) and amount of coins recieving. I’ve been trying to make it but I havent been able to make it so the player place goes with the KO.

example:

Are you having trouble saving/loading data? Check here to make sure you are saving properly.

I’m not having saving or loading data error, I’m trying to make a leaderbaord result thing

Provide any errors if you got any. Also provide the part of the script you think is causing the problem.

there isn’t any error I’m asking how to make something

this video could help
I now realise it might not be what you are looking for

ye It isn’t because thats a gobal leaderboard and I think it might be sorted in a different way with the service it use and the normal tables would’ve been sorted in the normal way.

Can I see the script you are using?

Yeah, I would like to know how to sort things as well, bump.

There isn’t anything wrong with the script, I know how to use table.sort but the problem is that how would I make it so it does table.sort and it would know what ko belong to which player(sorry if this doesn’t make sense I will rephase it if you want)

local PlayersKO = {}
local Placed = {}

	local Place = 1
	
	for i, player in pairs(game.Players:GetChildren()) do
		player:LoadCharacter()
		game.ReplicatedStorage.RemoteEvent.LeaderBoard:FireClient(player)	
		table.insert(PlayersKO,player.KO.Value)
	end

table.sort area

	for i, v in pairs(PlayersKO) do
		Placed[i] = Place
		Place = Place +1
	end
	
	for i, v in pairs(Placed) do
		for index, player in pairs(game.Players:GetChildren()) do
			local LeaderBoard = player.PlayerGui.Podium.LeaderBoard

			local CloneFrame = LeaderBoard.FrameHolder.Frame:Clone()

			CloneFrame.Place.Text = v
			CloneFrame.UserName.Text = i
			CloneFrame.KO.Text = "KO:"..tostring(PlayersKO[i].KO)
			CloneFrame.Money.Text = "+"..tostring(game.ReplicatedStorage.Money.Placement:FindFirstChild(v).Value)
			CloneFrame.Parent = LeaderBoard.FrameHolder
		end
	end

A lot of things in the script is irrelevent btw

I guess you can put all the information into a table AND then put that table into the main table

then you can fetch the KO stats from inside that table that is inside the main table

from their you can get the other information since its in the same table as the KO stats

ye that could work but how would I know which KO value belong to which table after sorting it.

let me try that out and I will see if I run into a problem

What I can think of at the moment is somehow sort the tables inside the main table based on the KO values, so that the index can be like the place and will also hold the information correctly. Then you can create the contents of the leaderboard using that.

How do I make a new table for every player in the server, I think dictionary is basically what you mean but dictionary cant be sorted with table.sort unfortunately

You can use a UIListLayout and GuiObject.LayoutOrder to sort the list.

1 Like

omg how have i forgot that thing exist lol thank you

That worked out for the gui order but now I can’t sort out the player place