Project index/03 — Luau
Case study / 03Source-inspected

Zone System.

Server-owned zone membership using tagged Roblox regions, local-space geometry, and entry/exit signals.

CategoryLuau
FocusServer zone tracking and geometry modules
TechnologyLuau / Roblox tags / Overture / RunService
StatusSource-inspected
01 / Overview

Why it exists

Give server systems a shared way to query which players occupy a named zone or sub-zone.

Spatial membership needs one registration path, repeatable containment checks, and cleanup when players or zones leave.

Based on the Zone System code in the local commons-area repo.

02 / System

How it works

  1. 01

    Register zones

    ZoneService binds tagged instances, creates ZoneClass objects, and indexes IDs and sub-zone relationships.

  2. 02

    Read geometry

    ZoneClass collects BaseParts and tests positions in each part's local coordinate space, with optional padding.

  3. 03

    Scan players

    A Heartbeat accumulator runs a scan at a 0.2-second interval over tracked players and registered zones.

  4. 04

    Publish membership

    The service updates player/zone lookup tables and fires entered or exited callbacks.

  5. 05

    Clean up

    Unregistration and player removal clear memberships, indexes, signals, and owned connections.

03 / Code

Selected code

These excerpts are from the paths shown on each patch. Select an annotation for a focused note; copy code directly from each patch.

luau / source excerpt

ZoneService.luau

commons-area/src/server/Services/ZoneService.luau

Scans tracked player roots, marks observed occupants, and exits players not seen in this pass. This is the membership update path.

Notes on the patch
luau / source excerpt

init.luau

commons-area/src/server/Modules/Classes/ZoneClass/init.luau

Checks a point against each live region part in local coordinates. This lets rotated parts participate in zone geometry.

Notes on the patch
04 / Decisions

Engineering decisions

01

Server-owned membership

Reason
The service reads server-side player roots and exposes one membership state to consumers.
Alternative
Let each client decide zone membership.
Tradeoff
The server performs periodic checks and transitions may be delayed by the scan interval.
02

Local-space containment

Reason
PointToObjectSpace allows a rotated BasePart to define a zone without axis-aligned approximations.
Alternative
Compare world-space axis-aligned bounds.
Tradeoff
Each containment test transforms the position for each zone part.
05 / Reflection

Outcome & next steps

Outcome

The source implements tagged zone registration, membership indexes, hierarchy queries, and server-side entry/exit callbacks.

What improved

Containment geometry and membership state are separate modules, so consumers can query zones without reimplementing spatial checks.

Current limitations

  • No zone-count benchmark or Studio runtime result was verified in this audit.
  • Membership is scanned periodically rather than updated continuously.

Future improvements

  • Add a Studio scenario covering rotated parts, nested IDs, removal, and scan timing.

What this demonstrates

Server-side spatial state, zone indexing, signal delivery, and lifecycle cleanup.

Continue readingODS Experiment