Want a special badge and 30 bux? Make some PolyWorld! Content and post it in the Creations forum!
Dark mode is incomplete! Please report any issues to the Discord.

StatsModule

Scripts Not creatable

StatsModule defines numeric player stats shown on the in-game player list.
Optionally saves values for logged-in accounts between sessions.
Available as the global StatsModule.

Guests never load or save. Only stats defined with Save = true are persisted.


Overview

Methods


API

Methods

Define

Define(name: string, options: table?) : void
Registers a stat column on the player list.
Call this once at place start (for example from a Script that also sets up teams).

OptionTypeDefaultMeaning
SaveboolfalsePersist for logged-in accounts when they leave
Defaultnumber0Value for new players / missing saves

Up to 8 stats per place. Names are case-sensitive and at most 23 characters.

StatsModule:Define("Kills", { Save = true, Default = 0 })
StatsModule:Define("Deaths", { Save = true })
StatsModule:Define("Streak", { Save = false, Default = 0 })

Set

Set(player: Player, name: string, value: number) : void
Sets a defined stat. Updates the player list for everyone in the place.

StatsModule:Set(player, "Kills", 0)

Get

Get(player: Player, name: string) : number
Returns the current value, or the Default if the player has no row yet.

Add

Add(player: Player, name: string, delta: number?) : number
Adds delta (default 1) and returns the new value.

Players.PlayerDied:Connect(function(player)
    StatsModule:Add(player, "Deaths", 1)
    StatsModule:Set(player, "Streak", 0)
end)

GetDefinitions

GetDefinitions() : List of tables
Returns { Name, Save, Default } for each defined stat, in definition order.


Player list

Defined stats appear as columns on the right of the player list.
Team headers from TeamsModule group rows when teams exist.