Leaderboard

A leaderboard shown on a player's HUD.

For examples on how to use, refer to UIService.

A leaderboard consists of entries (the rows displayed on the UI). Each entry has a key and a score associated with it.

  • Keys refer to the names of what is being ranked on the leaderboard. You can add Players, Teams, or words (strings) to the leaderboard.

  • Scores are the number displayed next to each key. The leaderboard entries are automatically ordered by descending scores. The rank of a key is its place.

Functions

getKeys(): Array<Player | Team | string>

Returns the keys of the leaderboard.

addKey(key: Player | Team | string, initialScore: number | nil)

Adds a new key to the leaderboard of the given type. You can optionally give the key an initial score, which otherwise defaults to zero.

removeKey(key: Player | Team | string)

Removes the key from the leaderboard.

addScore(key: Player | Team | string, amount: number)

Adds the given amount to the current score of the key.

subScore(key: Player | Team | string, amount: number)

Subtracts the given amount from the current score of the key.

setScore(key: Player | Team | string, amount: number)

Sets the score of the key to the given amount.

getScore(key: Player | Team | string): number | nil

Returns the current score of the key. Returns nil if the key is not part of the leaderboard.

getPlace(place: number): Player | Team | string | nil

Returns the key located at the place. Returns nil if there is no key at the place.

clear()

Clears all leaderboard entries.

Last updated