Messages
Stats
A stats message updates everything the dashboard shows for this account: labelled values and item lists.
Example
Luau
ws:Send(http:JSONEncode({
types = "stats",
stats = {
{ label = "Test", value = math.random(1, 12) },
{ label = "Number", value = 9999 },
{ label = "Number (M)", value = 12000000 },
{ label = "String", value = "this is string" },
},
items = {
{
name = "Testing Inventory",
types = "inventory", -- uses "count"
data = {
{ name = "Test 1", count = 1, icon = 732391129 },
{ name = "Test 2", count = 2, icon = 732391129 },
{ name = "Test 3", count = 3, icon = 732391129, imageOffset = {1, 1}, imageSize = {150, 150} },
}
},
{
name = "Testing Weapon",
types = "weapon", -- uses "mastery"
data = {
{ name = "Test 1", mastery = 1, icon = 732391129 },
{ name = "Test 2", mastery = 2, icon = 732391129 },
{ name = "Test 3", mastery = 3, icon = 732391129, imageOffset = {1, 1}, imageSize = {150, 150} },
}
},
}
}))Fields
| Field | Type | Description |
|---|---|---|
types | "stats" | Message type. Must be "stats". |
stats | { Stat } | List of labelled values. Add as many as you need. |
itemsoptional | { ItemGroup } | List of item groups. See Items. |
Stat
| Field | Type | Description |
|---|---|---|
label | string | Name shown on the dashboard. |
value | number | string | The value. Send big numbers as raw numbers (12000000), not pre-formatted strings. |
Luau
stats = {
{ label = "Level", value = 42 },
{ label = "Coins", value = 12000000 },
{ label = "Rank", value = "Diamond" },
}Refreshing
Each stats message is a full update. To keep the dashboard live, send it in a loop using refresh_time from your settings:
Luau
local function sendStats()
ws:Send(http:JSONEncode({
types = "stats",
stats = {
{ label = "Coins", value = plr.leaderstats.Coins.Value },
},
}))
end
while task.wait(synchronization.refresh_time) do
sendStats()
endTip
Run the loop in task.spawn if the script needs to do anything after it, since a while loop blocks the rest of the script.