Skip to content

ReferenceStates, zones, net events, instances, decals

Zones ​

Sphere, rotated box or polygon, with enter and exit. Checked by your resource itself: every 150 ms on the client, every 500 ms on the server for every player (or interval).

lua
local zone = RLX.AddZone({
  type = "box", coords = { x = 215.0, y = -810.0, z = 30.0 }, size = { x = 10, y = 6, z = 4 }, heading = 30,
  onEnter = function(zone) RLX.ShowNotification("Welcome") end,
  onExit = function(zone) end,
  inside = function(zone) end,   -- client only: every frame while inside
  debug = true,                  -- client only: drawn in the world
})

-- type = "sphere": coords, radius
-- type = "poly": points = { { x, y }, ... }, minZ, maxZ
-- dimension = 12: only in that instance; data = {...}: your own data, kept on the zone
  • On the server, onEnter(source, zone) and onExit(source, zone), and zone.players holds { [source] = true }.
  • On the client, zone.isInside tells whether the player is in it.
  • zone:contains(coords), zone:remove(), RLX.GetZone(id), RLX.RemoveZone(id).
  • A wrong definition returns nil and the reason: RLX.AddZone({ type = "poly", points = { ... } }) with fewer than 3 points gives nil, "poly: 3 points or more expected".