Greetings! I am trying to figure out how to get the player’s place on a World Record leaderboard.
ReplicatedStorage.WorldRecord.GetWorldRecord.OnServerInvoke = function(Player)
local WorldRecordList = GetLeaderboard()
local Place = 1
for PlayerID, Time in pairs(GetLeaderboard()) do
if PlayerID == Player.UserId then
break
else
Place += 1
end
end
return GetLeaderboard(), WorldRecords:GetAsync(Player.UserId) -- Will change this later.
end
-- The GetLeaderboard() function:
local function GetLeaderboard()
local Pages = WorldRecords:GetSortedAsync(true, 100)
local TopPlayers = Pages:GetCurrentPage()
return TopPlayers
end
However, I do not know what I should do if the player is not the top 100. I know that there is AdvanceToNextPageAsync()
, but I do not know how to properly use it.
If you can help, that will be appreciated!