OrderedStore
A saved list of scores by key that is sorted for leaderboards, which you get from data.ordered.
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.
Changes a key's score to a new number, replacing any increments made before it.
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.
Gives a key's score, or nil if the key has no score yet.
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.
Gives a key's place on the board, or nil if the key has no score yet.
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.
Gives up to 100 entries, with the highest scores first unless you ask for the lowest.
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.