Batch Operation Types
BatchOperation
Type for individual batch operations used in .BatchSetValues()
lua
export type BatchOperation = {
path: ValuePath,
value: any,
}Example:
lua
local operations: {BatchOperation} = {
{path = "Coins", value = 1000},
{path = "Level", value = 5},
{path = "Plot.Likes", value = 50},
{path = "Settings.MusicEnabled", value = true}
}BatchUpdateOperation
Type for increment/decrement operations used in .BatchUpdateValues()
lua
export type BatchUpdateOperation = {
path: ValuePath,
operation: "Increment" | "Decrement",
amount: number?,
}Example:
lua
local operations: {BatchUpdateOperation} = {
{path = "Coins", operation = "Increment", amount = 100},
{path = "Lives", operation = "Decrement"},
{path = "Plot.Likes", operation = "Increment", amount = 5}
}Notes:
- The same path can appear more than once and every operation is applied, so two
Incrementoperations of5onCoinsadd10. - When a batch writes the same tracked leaderboard stat several times, only the final value is sent to the leaderboard.
LeaderboardEntry
Type for leaderboard entries returned by leaderboard functions.
lua
export type LeaderboardEntry = {
userId: number,
score: number,
rank: number,
}Example:
lua
local leaderboardEntry: LeaderboardEntry = {
userId = 123456789,
score = 1500,
rank = 1
}
-- Leaderboard array
local leaderboard: {LeaderboardEntry} = {
{userId = 123456789, score = 1500, rank = 1},
{userId = 987654321, score = 1200, rank = 2},
{userId = 555666777, score = 1000, rank = 3}
}LeaderboardInfo
Type for the local player's leaderboard info synced to the client.
lua
export type LeaderboardInfo = {
rank: number?,
score: number?,
statName: string,
}Notes:
- This is derived from the replicated
_LeaderboardRankstable. - It is temporary display data and is not intended to be saved into player data.
- Players who join after the first player can read it (and
) on the client right after their data loads.GetLeaderboard()