[ QuickZone ]
60 FPS While ZonePlus and SimpleZone Drop To 5 FPS
99.6% Memory Reduction Compared To ZonePlus and 5x Smaller Than SimpleZone
Why use QuickZone?
The Physics Bottleneck. Traditional zone libraries like ZonePlus are basically wrappers for Roblox’s physics engine. This results in expensive geometry calculations, unpredictable overhead, low flexibility, and much worse performance as the number of zones grows.
Physics-Free Scaling. QuickZone achieves O(N log Z) scaling using a custom Linear Bounding Volume Hierarchy (LBVH), making the number of zones virtually irrelevant to performance. That, plus the use of SoA and bitwise spatial sorting, makes QuickZone the fastest way to do spatial queries.
Agnostic. Whether you prefer classic event-driven programming, robust lifecycle management, or zero-allocation iterators for ECS architectures, QuickZone can fit your workflow.
Unit Tested. A rigorous unit testing suite ensures stable and predictable behavior across all systems.
Core Features
-
Endless Scale: The number of zones has zero impact on performance. Maintain 60 FPS even with over a million zones in your game.
-
Track Anything: Track Players, BaseParts, Models, Attachments, Bones, Cameras, or even custom tables. If it has a position, QuickZone can track it.
-
Budgeted Scheduler: Set a hard frame budget (e.g., 1ms) to completely eliminate lag spikes. Workloads are smeared across frames to maintain a flat, predictable performance profile.
-
Shape Support: Built-in for Blocks, Balls, Cylinders, Wedges and CornerWedges without relying on physics collision meshes. MeshParts and Unions are supported through their collision geometry.
-
Declarative Lifecycles: Replace event-based logic with the observe pattern for declarative logic. There is no need to manually track
onEnterandonExitstates. -
Decoupled Architecture: Separate where tracking happens (Zones) from who is being tracked (Groups) and how the system responds (Observers). Bind complex behaviors to groups of entities with zero boilerplate.
-
ECS-Ready: Built-in support for zero-allocation iterators and deterministic manual stepping, making it a perfect fit for ECS architectures and data-oriented workflows
-
Zero-Allocation Runtime: By utilizing contiguous arrays and object pooling, QuickZone produces virtually zero GC pressure to avoid memory-related stutters.
-
Dynamic Zones: Use moving zones at very little cost. QuickZone maintains separate Static and Dynamic LBVHs for maximum efficiency.
Quick Setup
Getting started takes very little time. This is all you need to track every player across all zone parts tagged with ‘Checkpoint’.
-- Create and set up a checkpoint observer
local checkpointObserver = Observer.new({
zones = { Zone.fromTag('Checkpoint') }, -- create zones on parts with the 'Checkpoint' tag
groups = { Group.players() } -- tracks all players automatically
})
-- Observe players entering and exiting in just one block of code
checkpointObserver:observe(function(player, zone)
print(`{player.Name} entered checkpoint zone {zone:getId()}!`)
-- Return an optional cleanup function that runs automatically on Exit
return function()
print(`{player.Name} left checkpoint zone {zone:getId()}!`)
end
end)
Familiar with ZonePlus?
If you prefer a more imperative coding style or are migrating logic from other libraries, QuickZone supports method chaining and standard events.
-- Create and configure your observer in a single chain
local checkpointObserver = Observer.new()
:attach(checkpointZones)
:subscribe(playerGroup)
-- Use traditional events for one-off actions
checkpointObserver:onPlayerEnter(function(player, zone)
print(`{player.Name} entered`)
end)
checkpointObserver:onPlayerExit(function(player, zone)
print(`{player.Name} left!`)
end)
How It Works
QuickZone is not instance-bound. It uses a Group-Observer-Zone topology, separating who is being tracked from where the tracking occurs and how the system should respond.
Expand
The Secret to Performance
If you are coming from ZonePlus or SimpleZone, you are used to a “Zone-Centric” model where the Zone itself handles the logic. QuickZone flips this:
- ZonePlus: “Hey Zone, tell me when a player enters you.”
- QuickZone: “Hey Observer, tell me when this Group enters any of these Zones.”
The Three Pillars
- Zones (Where): Mathematical boundaries (Static or Dynamic).
- Groups (Who): Collections of entities (Players, NPCs, Projectiles) with shared update rates.
- Observers (How): The logic bridge. Define behavior once (e.g., “SafeZone Logic”) and attach it to as many zones as you need.
Anti-Gravity Example (Including ECS Style)
This section showcases an anti-gravity system. QuickZone supports three coding styles, so choose the one that fits your architecture.
Expand
Option A: The Lifecycle Approach (Recommended)
Best for clean, modern code. You define relationships in a configuration table (Declarative) and use a single function to manage the active state (Lifecycle)
local QuickZone = require(game.ReplicatedStorage.QuickZone)
local Zone, Group, Observer = QuickZone.Zone, QuickZone.Group, QuickZone.Observer
-- Create a group that automatically tracks the client's character (including respawns)
local myPlayer = Group.localPlayer()
-- Find all current and future instances with the 'Water' tag.
local zones = Zone.fromTag('AntiGravity', {
metadata = { GravityMultiplier = 0.4 }
})
-- Create an observer subscribed to the group and attached to the zones.
local gravityObserver = Observer.new({
groups = { myPlayer },
zones = { zones }
})
-- Define behavior
gravityObserver:observe(function(player, zone)
local character = player.Character
local hrp = character and character:FindFirstChild('HumanoidRootPart')
if not hrp then return end
-- Get the zone's gravity multiplier using metadata.
local meta = zone:getMetadata()
local multiplier = meta and meta.GravityMultiplier or 1
-- Create the Anti-Gravity force on enter
local force = Instance.new('BodyForce')
force.Name = 'AntiGravityForce'
force.Force = Vector3.new(0, hrp.AssemblyMass * workspace.Gravity * (1- multiplier), 0)
force.Parent = hrp
-- Automatically destroy the force when the player exits the zone
return function()
force:Destroy()
end
end)
Option B: The Event-Driven Approach (ZonePlus / SimpleZone Style)
Best for familiarity or for migrating ZonePlus code to QuickZone. You manually ‘wire’ objects together (Imperative) and use standard events like onEnter to trigger one-off actions (Event-Driven).
local QuickZone = require(game.ReplicatedStorage.QuickZone)
local Zone, Group, Observer = QuickZone.Zone, QuickZone.Group, QuickZone.Observer
local localPlayer = game:GetService('Players').LocalPlayer
local myPlayer = Group.localPlayer()
local zones = Zone.fromChildren(workspace.AntiGravityParts)
local gravityObserver = Observer.new():subscribe(myPlayer):attach(zones)
-- Connect events
gravityObserver:onLocalPlayerEnter(function(zone)
local character = localPlayer.Character
local hrp = character and character:FindFirstChild('HumanoidRootPart')
if not hrp then return end
local ref = zone:getReference() -- This returns the zone's part
local multiplier = ref and ref:GetAttribute("GravityMultiplier") or 1 -- You can use attributes!
local force = Instance.new('BodyForce')
force.Name = 'AntiGravityForce'
force.Force = Vector3.new(0, hrp.AssemblyMass * workspace.Gravity * (1- multiplier), 0)
force.Parent = hrp
end)
gravityObserver:onLocalPlayerExit(function(zone)
local character = localPlayer.Character
local hrp = character and character:FindFirstChild('HumanoidRootPart')
if hrp and hrp:FindFirstChild('AntiGravityForce') then
hrp.AntiGravityForce:Destroy()
end
end)
Option C: The Polling Approach (Data-Oriented / ECS)
Use iterators to poll state for continuous logic. To enhance ECS workflows, you can also turn off auto-updating and update QuickZone manually. It is even possible to manually link entities to a reference like an Id or an object.
local Players = game:GetService('Players')
local RunService = game:GetService("RunService")
local QuickZone = require(game.ReplicatedStorage.QuickZone)
local Zone, Group, Observer = QuickZone.Zone, QuickZone.Group, QuickZone.Observer
-- Disable auto-update for deterministic, manual stepping (optional)
QuickZone:setEnabled(false)
local localPlayer = Players.LocalPlayer
local characterModel = localPlayer.Character or localPlayer.CharacterAdded:Wait()
-- Track this Model's physical position, but return the local player in queries
QuickZone:setReference(characterModel, localPlayer)
-- Add the local player to the spatial group (QuickZone tracks the mapped model automatically)
local playerGroup = Group.new():add(localPlayer)
local zones = Zone.fromTag('AntiGravity', {
metadata = { GravityMultiplier = 0.4 }
})
local gravityObserver = Observer.new({
groups = { playerGroup },
zones = { zones }
})
-- Process all spatial movement and LBVH tree updates in a specific order (only needed if :setEnabled(false))
local function spatialSystem(dt)
QuickZone:update(dt)
end
local function gravitySystem(dt)
-- Instead of creating a BodyForce, we apply continuous math statelessly.
for player, zone in gravityObserver:iterEntitiesInside() do
local character = player.Character
local hrp = character and character:FindFirstChild('HumanoidRootPart')
if not hrp then continue end
local meta = zone:getMetadata()
local multiplier = meta and meta.GravityMultiplier or 1
local upwardForce = hrp.AssemblyMass * workspace.Gravity * (1- multiplier)
hrp:ApplyImpulse(Vector3.new(0, upwardForce * dt, 0))
end
end
RunService.Heartbeat:Connect(function(dt)
spatialSystem(dt)
gravitySystem(dt)
end)
Usage Guide
QuickZone is designed around a three-tier architecture: Zones (where), Groups (who), and Observers (how).
Expand
1. Zones (Where)
Zones represent physical areas in the world. They are mathematical boundaries that can be static (fixed in space) or dynamic (following a part). They can be created from existing parts or defined manually with a CFrame and Size.
Bulk Creation
The easiest way to create zones is using the bulk constructors. The fromParts, fromDescendants, fromChildren, and fromTag return a Zones collection object, which acts as a logical unit allowing you to manage multiple zones at once.
-- Create zones from a CollectionService tag
local lavaZones = Zone.fromTag('Lava', {
metadata = { damage = 10 }
})
-- Create zones from an array of parts
local safeZones = Zone.fromParts(workspace.SafeZones:GetChildren())
-- Create zones from all BaseParts inside a Model or Folder (Deep search)
local hazardZones = Zone.fromDescendants(workspace.TrapModel)
-- Create zones from only the direct children of a Folder (Shallow search)
local flatZones = Zone.fromChildren(workspace.FlatFolder)
Manual Creation
Useful for procedural generation or areas without physical parts.
local zone = Zone.new({
cframe = CFrame.new(0, 10, 0),
size = Vector3.new(10, 10, 10),
shape = 'Block',
isDynamic = true,
metadata = { Name = 'Lobby' }
})
Single & Dynamic Creation
For maximum perfomance, use isDynamic = true for zones attached to moving platforms, vehicles, or projectiles.
local trainZone = Zone.fromPart(workspace.TrainCarriage, {
isDynamic = true,
metadata = { route = 'North' }
})
Updating Zones
Dynamic zones need to know when their physical reference moves. You can let QuickZone handle this automatically or control it manually.
You can quickly create a dynamic zone from an existing physical part. If you set autoSync = true, QuickZone will automatically update the zone’s position in the spatial tree every frame to match the part.
local truckZone = Zone.fromPart(workspace.Truck.Hitbox, {
isDynamic = true,
autoSync = true
})
Because Zone.fromPart requires an object with a physical volume (like a BasePart), you cannot use it for abstract references like an Attachment or a Bone. Instead, you manually create the zone with a specific size and declaratively set its reference and autoSync.
local trainZone = Zone.new({
cframe = train.CabinAttachment.WorldCFrame,
size = Vector3.new(15, 10, 30),
shape = 'Block',
reference = train.CabinAttachment,
autoSync = true, -- QuickZone automatically moves the dynamic zone with the attachment every frame!
metadata = { route = 'North Express' }
})
Manual Syncing
If you prefer strict control over when spatial updates happen, leave autoSync off and update the zone manually.
-- Manually move a dynamic zone
dynamicZone:setPosition(Vector3.new(0, 50, 0))
-- Sync a dynamic zone to references's current CFrame, Size, and Shape
dynamicZone:sync()
2. Groups (Who)
Groups are collections of entities (Parts, Models, Players, etc.).
Specialized Groups
QuickZone provides built-in abstractions that automatically handle player lifecyles.
-- Tracks all players in the server
local allPlayers = Group.players()
-- Tracks only the local player (client-side only)
local myPlayer = Group.localPlayer()
Custom Groups
For NPCs, projectiles, or vehicles, create a standard Group.
local projectiles = Group.new({
entities = workspace.Projectiles:GetChildren()
})
Managing Entities
You can add BaseParts, Models, Attachments, Bones, or tables with a Position.
-- Add a Model (tracks the PrimaryPart or Pivot)
enemies:add(npcModel)
-- Add a specific Attachment (tracks the exact point)
-- This is great for offsets if you do not want to track the middle of a part (e.g. sword tip)
enemies:add(sword.TipAttachment)
-- Add a table
local spell = { Position = Vector3.new(10, 5, 0) }
enemies:add(spell)
-- Clear the enemies group when done
enemies:clear()
3. Observers (How)
Observers act as the logic layer. They subscribe to Groups and attach to Zones to bridge spatial data with game behavior.
Setup
An Observer listens to its subscribed Groups and checks if they overlap with its attached Zones.
local observer = Observer.new({
updateRate = 60, -- Check up to 60 times a second
precision = 1.0, -- Only query if the entity moves more than 1 stud
priority = 5 -- Used to resolve overlapping zones
})
observer:subscribe(allPlayers)
observer:attach(healingZones)
Lifecycle Management
For logic that should persist while an entity is inside a zone (e.g., UI, music, status effects), use the observe methods. These accept a callback that returns a cleanup function, which runs automatically when the entity exits.
-- Generic observation
observer:observe(function(entity, zone)
print('Entered', entity)
local highlight = Instance.new('Highlight', entity)
return function()
print('Exited', entity)
highlight:Destroy()
end
end)
-- The callback fires when the first entity of a group enters, and the
-- returned cleanup function fires when the last entity of the group leaves.
observer:observeGroup(function(group, zone)
print('Group ' .. group:getId() .. ' has arrived!')
local boss = workspace.Boss:Clone()
boss.Parent = workspace
return function()
print('The group has been wiped out or left.')
boss:Destroy()
end
end)
-- Player specific
observer:observePlayer(function(player, zone)
local forceField = Instance.new('ForceField', player.Character)
return function()
forceField:Destroy()
end
end)
-- LocalPlayer specific
observer:observeLocalPlayer(function(zone)
local sound = workspace.Sounds.SafeZoneAmbience
sound:Play()
return function()
sound:Stop()
end
end)
Events
For logic that happens exactly once on entry or exit (e.g., playing a sound effect, dealing damage, analytics), use the event listeners.
-- Individual entity events
observer:onEnter(function(entity, zone)
print(entity.Name .. ' entered ' .. zone:getId())
end)
observer:onExit(function(entity, zone)
print(entity.Name .. ' exited ' .. zone:getId())
end)
-- Transition event (Fires when swapping between overlapping zones within the same observer)
observer:onTransition(function(entity, newZone)
print(entity.Name .. ' seamlessly moved to a new zone without leaving the area!')
end)
-- Group-level events
observer:onGroupEnter(function(group, zone)
print('The first member of group ' .. group:getId() .. ' entered!')
end)
observer:onGroupExit(function(group, zone)
print('The last member of group ' .. group:getId() .. ' left!')
end)
-- Convenient player events
observer:onPlayerEnter(function(player, zone) ... end)
observer:onPlayerExit(function(player, zone) ... end)
observer:onPlayerTransition(function(player, newZone) ... end)
observer:onLocalPlayerEnter(function(zone) ... end)
observer:onLocalPlayerExit(function(zone) ... end)
observer:onLocalPlayerTransition(function(newZone) ... end)
Handling Overlapping Zones (Transitions vs. Priorities)
When zones physically overlap in the world, QuickZone offers two distinct architectural patterns to handle them, depending on your goal.
Observers use a priority system to handle overlapping zones. An entity ‘belongs’ to only one zone state per observer at a time when using priorities.
Pattern 1: The Data-Driven Pattern (Single Observer + Transitions)
Best for: Systems that share the exact same logic, but use different values (e.g., all Environmental Hazards, all Healing Zones, all XP Zones).
If a player walks from a Lava zone into an overlapping SuperLava zone attached to the same observer, they never actually “left” the observer’s overall coverage area. Therefore, onExited and onEntered will not fire. Instead, the engine fires an onTransitioned event.
This allows you to update metadata instantly!
hazardObserver:observePlayer(function(player, initialZone)
local currentDamage = initialZone:getMetadata().Damage or 10
local active = true
local disconnectTransition = hazardObserver:onPlayerTransitioned(function(transitioningPlayer, newZone, oldZone)
if transitioningPlayer ~= player then return end
currentDamage = newZone:getMetadata().Damage or 10
print(player.Name .. " transitioned. New damage: " .. currentDamage)
end)
task.spawn(function()
while active do
player.Character.Humanoid:TakeDamage(currentDamage)
task.wait(1)
end
end)
return function()
active = false
disconnectTransition() -- Clean up the listener
end
end)
Pattern 2: The State-Machine Pattern (Multiple Observers + Priorities)
Best for: Systems with mutually exclusive logic that need to strictly override each other (e.g., Camera Filters, Music Tracks, UI States).
If you have overlapping zones that do fundamentally different things, you should attach them to different observers and assign them a Priority. QuickZone’s engine will automatically force the entity out of the lower-priority observer and into the higher-priority one.
local lowPriority = Observer.new({ priority = 0 })
local highPriority = Observer.new({ priority = 10 })
-- If a player is inside Zone A (Low) and Zone B (High) simultaneously:
-- 1. highPriority:onEntered() fires for Zone B.
-- 2. lowPriority:onExited() fires for Zone A.
Observer State
Observers can be toggled to pause logic without destroying the configuration.
observer:setEnabled(false) -- Fires 'onExited' for everyone inside
task.wait(5)
observer:setEnabled(true) -- Fires 'onEntered' if they are still there
Benchmarks
QuickZone significantly outperforms the most popular zone libraries. We benchmarked it in two distinct scenarios: High Zone Count and High Entity Count.
Expand
Scenario 1: High Zone Count
Scenario: 500 moving entities, 10,000 zones, recorded over 30 seconds.
This test highlights the fundamental flaw in traditional Zone-Centric libraries. As map complexity grows, their performance degrades massively.
| Metric | QuickZone | ZonePlus | SimpleZone | QuickBounds | Empty Script |
|---|---|---|---|---|---|
| FPS | 59.33 | 3.84 | 5.53 | 58.95 | 59.28 |
| Events/s | 648 | 627 | 519 | 328 | 0 |
| Memory Usage (MB) | 18.57 | 4230 | 99.79 | 17.62 | 0.65 |
The Result: QuickZone maintained a perfect 60 FPS.
-
ZonePlus and SimpleZone imploded, dropping to 3-5 FPS, making the game unplayable.
-
ZonePlus consumed over 4 GB of memory, which would crash most mobile devices instantly.
-
QuickZone vs. QuickBounds: Both libraries scaled well by maintaining ~60 FPS. However, QuickZone still maintained a slight FPS lead and, more importantly, delivered double the event throughput (643 vs 328) compared to QuickBounds.
Scenario 2: High Entity Count
Scenario: 2,000 moving entities, 100 zones, recorded over 30 seconds.
| Metric | QuickZone | ZonePlus | SimpleZone | QuickBounds | Empty Script |
|---|---|---|---|---|---|
| FPS | 42.37 | 29.88 | 37.23 | 41.31 | 42.73 |
| Events/s | 2271 | 2482 | 2518 | 566 | 0 |
| Memory Usage (MB) | 2.13 | 159 | 1.77 | 2.60 | 1.04 |
The Result: QuickZone is the only library that maintained near-baseline FPS (-1% impact).
-
ZonePlus caused a 28% drop in framerate, and SimpleZone decreased by 13%.
-
QuickZone handled the load with 98% less memory than ZonePlus.
-
QuickZone vs. QuickBounds: QuickZone averages ~1 FPS higher than QuickBounds. More importantly, QuickZone processed 4x the volume of events (2,271 vs 566).
Note: For the QuickZone benchmark, we used a frame budget of 1ms, the entities’ update rate was set to 60Hz, and precision was 0.0.
Limitations
Expand
-
Point-Intersection: QuickZone tracks the precise coordinate of an entity. It does not account for the full volume of the entity itself.
Note: Ensure that zones encapsulate the center of the entity like a player’s HumanoidRootPart. Otherwise, theonEnteredandonExitedevents will not fire. -
Budgeted Latency: To prevent frame drops, QuickZone ‘smears’ workload across multiple frames. In high-load scenarios (e.g., thousands of active entities), there may be a slight delay (like 1-2 frames) between an entity physically entering a zone and the event firing.
Installation
Expand
Wally
Add the following to your wally.toml file:
ldgerrits/quickzone@1.4.7
NPM
For roblox-ts projects, install the package as follows:
npm i @rbxts/quickzone
Manual
Get QuickZone from the Creator Store. Alternatively, download the latest .rbxm model file from the Releases tab and drag it into ReplicatedStorage.
