Leaderboards and OrderedDataStores
Build global and friend leaderboards with OrderedDataStore, stat tracking, and UI integration.
Introduction
Leaderboards drive competition and retention. Roblox provides built-in leaderstats for session stats and OrderedDataStore for persistent global rankings. This hub covers both approaches with UI integration patterns.
Session Leaderstats
Create a Folder named 'leaderstats' in the player object. Add IntValue children for each stat. These appear in the default Roblox leaderboard automatically. Update values server-side. Leaderstats reset each session—they are not persistent.
Global Rankings with OrderedDataStore
OrderedDataStore stores numeric scores sortable across all players. Use :SetAsync(userId, score) and :GetSortedAsync(false, pageSize) for top-N queries. Cache results and refresh periodically—OrderedDataStore has strict rate limits.
Use Cases
- High score tracking
- Weekly competitions
- Friend rankings
Best Practices
- Cache leaderboard data client-side
- Rate-limit score submissions
- Validate scores server-side
Troubleshooting
Script runs but nothing happens in-game
Verify the script type matches its location. Server Scripts belong in ServerScriptService; LocalScripts in StarterPlayerScripts or StarterGui. Check the Output window in Studio for error messages.
Changes don't appear after editing
Stop and restart Play mode in Studio. Some scripts cache values on first run. For published games, republish after testing locally.