Skip to content
Untitled Sandbox - Developer Documentation
docs/types/OrderedStore

OrderedStore

A saved list of scores by key that is sorted for leaderboards, which you get from data.ordered.

Fields

namestring

OrderedStore:increment

method

Adds an amount to a key's score, 1 if you don't give one, and gives back the new score.

OrderedStore:increment(key: string | number, amount: number?) -> number
example
wins:increment(player.user_id, 1)

Use it foradding a win to a player's score each time they win a round.

keyWhose score, often a player's user_id.
amountoptionalHow much to add. 1 by default.

OrderedStore:set

method

Changes a key's score to a new number, replacing any increments made before it.

OrderedStore:set(key: string | number, score: number) -> ()
example
wins:set(player.user_id, 10)

Use it forsaving a player's new best lap time when they beat their old one.

keyWhose score, often a player's user_id.
scoreThe new score.

OrderedStore:get

method

Gives a key's score, or nil if the key has no score yet.

OrderedStore:get(key: string | number) -> number?
example
local best = wins:get(player.user_id)

Use it forshowing a player how many wins they have in total when they join.

keyWhose score, often a player's user_id.

OrderedStore:rank

method

Gives a key's place on the board, or nil if the key has no score yet.

OrderedStore:rank(key: string | number) -> number?
example
local place = wins:rank(player.user_id)

Use it fortelling a player that they are in 5th place on the leaderboard.

keyWhose score, often a player's user_id.

OrderedStore:top

method

Gives up to 100 entries, with the highest scores first unless you ask for the lowest.

OrderedStore:top(count: number?, ascending: boolean?) -> { OrderedEntry }
example
for _, entry in wins:top(10) do print(entry.rank, entry.key, entry.value) end

Use it forshowing an all-time leaderboard in the lobby, with the best players at the top.

countoptionalHow many entries, a whole number from 1 to 100. 10 by default.
ascendingoptionalTrue gives the lowest scores first.
↑ ↓ moveEnter openEsc close