Skip to content

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.

SetPlayerData(pid, key, value)
Parameter Type
pid number the player
key string the key
value any the value; nil removes the key

boolean - false when not connected

SetPlayerData(pid, "team", "red")
SetPlayerData(pid, "kills", (GetPlayerData(pid, "kills") or 0) + 1)

GetPlayerData · SetSavedData · SetPlayerState · the Storage and persistence group of the index