SetPlayerData
Stores a value on the player, private to the server, for the session.
Any Lua value - a string, a number, a boolean, a table. Cleared when the player disconnects and on a reload. Never
replicated: for a value the clients read use SetPlayerState; for one that should survive the visit, SetSavedData.
Syntax
Section titled “Syntax”SetPlayerData(pid, key, value)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
key |
string | the key |
value |
any | the value; nil removes the key |
Returns
Section titled “Returns”boolean - false when not connected
Example
Section titled “Example”SetPlayerData(pid, "team", "red")SetPlayerData(pid, "kills", (GetPlayerData(pid, "kills") or 0) + 1)See also
Section titled “See also”GetPlayerData · SetSavedData · SetPlayerState · the Storage and persistence group of the index
