Player Data¶
PlayerService and PlayerDataService are the two complementary services that together manage everything about a player's runtime state and their persisted profile.
PlayerDataService¶
Owns the ProfileService store and is the single source of truth for persisted player data. When a player joins, PlayerAdded fires, a profile is loaded asynchronously, and OnProfileLoaded grants their owned weapons and tools, sets up the leaderstats money value, and begins tracking playtime.
Data Template¶
The default profile for a new player looks like this:
| Field | Default | Description |
|---|---|---|
Money |
837 | In-game currency |
Chips |
0 | Premium currency |
LatestVehicle |
Solara EcoLite | Last driven vehicle, used to auto-spawn on join |
Vehicles |
{ "Solara EcoLite": { owned: true } } |
Owned vehicle registry |
OwnedWeapons |
{ "Pistol": { equipped: true, ammo: 85 } } |
Weapon inventory with per-weapon ammo |
PlaytimeInMinutes |
0 | Lifetime playtime, incremented every minute |
Tools |
{} |
Heist tools (e.g. Cutter) with durability |
Quests |
{} |
Quest completion state |
Key Functions¶
update(Player, Key, Value)— writes a top-level field and fires any registered observerincrement(Player, Key, Value)— shorthand forupdatewith an additive deltagetProfile(Player)— returns the raw ProfileService profile objectgetLatestVehicle(Player)/setLatestVehicle(Player, name)— read/write the last-used vehicle
Granting Items on Load¶
After a profile loads, grantOwnedTools and grantOwnedWeapons clone tools and weapons from ServerStorage into the player's Backpack. The same functions re-run on every CharacterAdded so items survive respawns. Weapons carry their saved ammo count and get a tooltip applied by GunShopService.
Playtime Tracking¶
A background loop runs every 60 seconds and accrues elapsed minutes into PlaytimeInMinutes for each active player, then resets the session start time.
PlayerService¶
Manages runtime, non-persisted player state: crime records, cop advisories, assigned NPC units, session flags, and Knit client properties that replicate live values to the client.
Client Properties (replicated live)¶
| Property | Type | What it drives |
|---|---|---|
Score |
number | Wanted star display |
Identified |
bool | Whether cops know who the player is |
RecognitionProgress |
number | 0–1 recognition fill before identification |
Suspicious |
bool | Whether the player is acting suspiciously |
ClientArrestTick |
number | Timestamp of last arrest, used for jail timer |
ClientSearchTick |
number | Timestamp of last search order, used by AI |
Crime Record¶
Each player carries a CrimeRecord table in their runtime session. It holds fields like Score, Identified, LastPosition, and advisory flags set by cops via CentralService:Advise. The record resets on respawn (recognition progress and Identified flag are cleared; the score is cleared separately by the crime/cashout flow).
Set / Get¶
PlayerService:Set(player, key, ...) and :Get(player, key, ...) are the generic accessors for anything in the runtime table. They support nested keys via variadic arguments so you can do :Set(player, "CrimeRecord", "Identified", true).