Skip to content

ReferenceStates, zones, net events, instances, decals

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 listening
  • RLX.OnStateChange(scope, key, fn): scope is "global", "player" or "entity" (or nil: all); key is one key (or nil: all). On the server, source is the player who wrote it (nil for 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 (security category). Protect your own keys with RLX.ProtectState("myres:") on the server.
  • States are not saved: they live as long as the player, the entity or the server session.