States (shared values)
Small values every client sees (LS:MP meta), with change events.
lua
-- Server
RLX.SetGlobalState("event", "carnival")
RLX.SetPlayerState(source, "phone", "555-0142")
RLX.SetEntityState(netId, "fuel", 0.75)lua
-- Both sides
local phone = RLX.GetPlayerState(playerId, "phone")
local off = RLX.OnStateChange("player", "phone", function(target, value, key, source) end)
off() -- stop listeningRLX.OnStateChange(scope, key, fn):scopeis"global","player"or"entity"(ornil: all);keyis one key (ornil: all). On the server,sourceis the player who wrote it (nilfor a script).- A client may write its own player and the entities it simulates (
RLX.SetPlayerState(myId, ...)). Never trust those values. - Protected states: keys starting with
rlx:(job, plate, vehicle props, fuel, locks) are server-only. A client write is undone at once and logged (securitycategory). Protect your own keys withRLX.ProtectState("myres:")on the server. - States are not saved: they live as long as the player, the entity or the server session.