CyberMax
CyberMax › Answers

Roblox global leaderboard: top players across every server

Updated 2026-10-17 · Roblox and game developers · by CyberMax

Short answer

Store each player's score in an OrderedDataStore keyed by UserId, then read the top entries with GetSortedAsync(false, 50) once every minute or two and show them on a SurfaceGui. Sorted reads have a small budget (5 + players × 2 a minute), so cache the page instead of reading it for every player.

  1. Make a Part with a SurfaceGui and a ScrollingFrame for the rows.
  2. Paste the script in ServerScriptService; fill the SurfaceGui from the `top` table in refresh().
  3. Values must be whole numbers: OrderedDataStore only stores integers.

Copy-paste code

ServerScriptService/GlobalBoard.server.lua

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local board = DataStoreService:GetOrderedDataStore("TopCoins_v1")

local function submit(player)
	local coins = player:FindFirstChild("leaderstats") and player.leaderstats.Coins.Value
	if coins then pcall(board.SetAsync, board, tostring(player.UserId), math.floor(coins)) end
end

local top = {} -- cached { {name = ..., score = ...}, ... }

local function refresh()
	local ok, pages = pcall(board.GetSortedAsync, board, false, 50)
	if not ok then return end
	local rows = {}
	for rank, entry in pages:GetCurrentPage() do
		local okName, name = pcall(Players.GetNameFromUserIdAsync, Players, tonumber(entry.key))
		rows[rank] = { name = okName and name or "?", score = entry.value }
	end
	top = rows
	-- update your SurfaceGui here from `top`
end

Players.PlayerRemoving:Connect(submit)
task.spawn(function()
	while true do
		for _, p in Players:GetPlayers() do submit(p) end
		refresh()
		task.wait(120)
	end
end)

Good to know

Names: GetNameFromUserIdAsync is a web call; cache names by UserId so a refresh doesn't look up the same 50 names every time.

Weekly boards: put the week number in the store name ("TopCoins_2026w42") so each week starts empty.

Studwright: Roblox systems that never lose saves

from $12

Studwright is 16 tested Luau modules: session-locked SaveData, Receipts (developer products granted once), Codes, DailyRewards, PlaytimeRewards, Leaderboard, LootTable, Inventory, Currency, RemoteGuard and more, as a drag-in .rbxmx with the tests.

Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)

Questions

Why is my global leaderboard empty?

OrderedDataStore needs integer values, and Studio needs API Services enabled. Check that SetAsync is being called with math.floor().

How many entries can I show?

GetSortedAsync returns up to 100 per page.

Can I sort ascending (fastest time)?

Yes: GetSortedAsync(true, 50).

Free: the Roblox Starter Kit

7 free Luau modules (damage, pets, shop formatting, admin audit log, tycoon guards and more) plus 3 free calculators, then 5 short emails with the scripting fixes we see go wrong most often.

You get one email to confirm first. Then the kit, and 5 short emails over two weeks. One-click unsubscribe in every email; we never share your address.

Related answers

Roblox leaderboard script: leaderstats you can copy and pasteA working Luau leaderstats script for the player list leaderboard, with coins and level values that save, plusRoblox DataStore limits: requests per minute, size per key, key namesThe DataStore limits from Roblox's docs: 60 + players × 40 reads and writes a minute, 4 MB per key, 50-charact