A global leaderboard ranks every player by a stat like total coins, and the ranking persists across servers. The hard part isn't the GUI — it's storing sorted data with OrderedDataStore and reading the top players back. This guide covers the full loop: save a score, fetch the top 10, and render them as rows. Start from the leaderboard template for the row layout.
1. Store ranked data with OrderedDataStore
An OrderedDataStore keeps values sortable. Use the player's UserId as the key and their score as the value, so each player appears once.
2. Read the top players
GetSortedAsync returns the entries in order. Pass false for descending (highest first) and a page size. GetCurrentPage gives the ranked list of { key, value }.
Tip: GetNameFromUserIdAsync is a web call — cache names so you don't re-fetch the same player every refresh.
