Skip to content
Random game

Leaderboards

Last updated 2026-11-20

A leaderboard ranks your players by their best score. Every board has three rankings: today (UTC), this week (UTC, Monday to Sunday) and all time. Your game page shows the first board you declare, beside the game on desktop and under it on phones, so players see where they stand.

Declare a board

Open your game in the dashboard, then Saves and boards. Each board has:

Field What it does
Board id The id your game passes to submitScore(), like best or level-1-time. 1 to 64 letters, digits, dots, dashes or underscores.
Name players see The title above the board on your game page, like “Best score”. 1 to 40 characters.
Best is Highest for points, Lowest for times.
Lowest score and Highest score The server refuses any score outside them. Set the highest to the best score your game can really give.
Wait (seconds) Seconds before the server takes another score from the same player on this board. 0 means no wait. Up to 86,400 (one day).

A game can have up to 10 boards. A score sent to an id you didn’t declare is refused. Clear a board’s id and save to delete it. Its scores are kept, and they come back if you add the same id again. A new or changed first board shows on your game page within about two minutes.

Send a score

async function onRunOver(score) {
  sdk.gameplayStop();
  const isOnBoard = await sdk.leaderboard.submitScore('best', score);
  sdk.gameEnd('loss');
  if (!isOnBoard) {
    console.log('This score was not added to the board.');
  }
}
  • score is a number. Send whole numbers when you can: the board shows scores rounded to whole numbers. For a time, send milliseconds.
  • Each player keeps their best score in each ranking. A lower score is still taken (it counts for the wait time), but it doesn’t change the player’s best.
  • Equal scores rank the player who reached it first higher.
  • It resolves true when the board took the score, and false when it didn’t. It never rejects.

submitScore() resolves false when:

Why What to do
The player is a guest Nothing. The board on your page asks them to sign in. Guests are never on boards.
The score is under the lowest or over the highest score Check your numbers, or raise the highest score in the dashboard.
The same player’s last score was inside the wait time Send one score per round, at the end.
The board id isn’t declared Declare it in the dashboard.
The score isn’t a finite number (NaN, Infinity, text) Fix the score. The inspector warns about these.

Read a board

getScores(boardId, options) reads a ranking: the best players, and the player’s own place.

const {entries, player} = await sdk.leaderboard.getScores('best', {period: 'weekly', limit: 5});
for (const entry of entries) {
  console.log(`#${entry.rank} ${entry.name}: ${entry.score}`);
}
if (player) {
  console.log(`You are #${player.rank} this week with ${player.score}.`);
}
Option Values Default
period 'daily', 'weekly', 'allTime' 'allTime'
limit 1 to 100 10
  • entries are best first. Each has rank (1 for the best), name (the player’s Foony name) and score.
  • player is the signed-in player’s own rank and score in that period, or null for a guest or a player with no score there yet.
  • With no page around the game, it resolves {entries: [], player: null}. It never rejects.
  • Read a board when the player opens it, not every frame.

Test it

In the inspector, every submitScore() call shows in the log, and Saves and scores shows each board’s scores. The inspector doesn’t know your board settings, so it takes every finite score. It warns when a score isn’t a finite number, and when your game sends more than 5 scores in 10 seconds.

The dashboard’s Saves and boards tab counts scores taken, scores refused and the players on each board over the last 28 days.