Leaderboard ties

hi i have a leaderboard that shows how many waves a player has made it to
the game is a team game so i want ties to hold the same spot, so if two people make it to wave 999 they should both be number 1

how would i do this

local function loadLeaderboards()
	local leaderboardPart = workspace.InfiniteLeaderboard
	local leaderboardUi = leaderboardPart.SurfaceGui.ScrollingFrame
	
	local success, leaderboardData = pcall(function()
		return leaderboards:GetSortedAsync(false, 50)
	end)

	if success then
		local page = leaderboardData:GetCurrentPage()
		
		for i, v in ipairs(page) do
			local rank = "#" .. i
			local frame = leaderboardUi:FindFirstChild(tostring(i)) -- i have special frames for #1, 2, and 3 to make them stand out
			
			if frame then
				frame = frame:Clone()
			else
				frame = leaderboardUi.Template:Clone()
			end
			
			local player = Players:GetNameFromUserIdAsync(v.key)
			
			frame.Parent = leaderboardUi
			frame.Plr.Text = player
			frame.Wave.Text = v.value
			frame.Rank.Text = rank
			
			
			
			
			frame.LayoutOrder = i
			frame.Name = i
			frame.Visible = true
		end
	end
end
1 Like

You could make a table that follows this syntax:

local t = {
    [1] : {Player1, Player2} -- The 1 there is the Wave, the table is the players located on that wave
}

Then, you update the table whenever the orderedDataStore updates with the player wave reached and the player name. When you make the leaderboard, you get the highest index of the table, gets the players from that index, and updates it by using a for loop, for example, with the players, creating two top ones.

I think you got it.

EDIT: I know you already marked this as the solution, but you can also make this syntax being the actual DS, instead of creating another table.

i dont know how i didnt think of this thanks

1 Like

It’s fine, don’t worry :). Good luck with your game :smiley:

would the method you added in the edit still work with ordered datastores or would i have to recode it to use normal ones

No, it would still work with ordered data stores. All you need to do is creating a table with the index being the wave and the value being the players standing on that wave.

However, as I said before, you can do that directly onto the ordered datastore