ZonePlus v3.2.0 | Construct dynamic zones and effectively determine players and parts within their boundaries

ZonePlus v3

:floppy_disk: Source Code | :open_book: Documentation | :ocean: Playground

ZonePlus utilises the new Spatial Query API and Whitelists to effectively determine players, parts and custom items within a zone. You can have as many zones as you like, as large as you like, with zero-to-minimal additional cost to performance.

For those looking to benefit from v3 you can find a detailed breakdown here.

-- This constructs a zone based upon a group of parts in Workspace and listens for when a player enters and exits this group
-- There are also the ``zone.localPlayerEntered`` and ``zone.localPlayerExited`` events for when you wish to listen to only the local player on the client
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = workspace.AModelOfPartsRepresentingTheZone
local zone = Zone.new(container)

zone.playerEntered:Connect(function(player)
    print(("%s entered the zone!"):format(player.Name))
end)

zone.playerExited:Connect(function(player)
    print(("%s exited the zone!"):format(player.Name))
end)
-- This constructs a zone based upon a region, tracks a Zombie NPC, then listens for when the item (aka the Zombie) enters and exits the zone.
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local zoneCFrame = CFrame.new()
local zoneSize = Vector3.new(100, 100, 100)
local zone = Zone.fromRegion(zoneCFrame, zoneSize)

zone.itemEntered:Connect(function(item)
    print(("%s entered the zone!"):format(item.Name))
end)

zone.itemExited:Connect(function(item)
    print(("%s exited the zone!"):format(item.Name))
end)

zone:trackItem(workspace.ZombieNPC)
-- This is a one-time use method which calls the given function when the given item enters the zone
local item = character:FindFirstChild("HumanoidRootPart")
zone:onItemEnter(item, function()
    print("The item has entered the zone!")
end)

:sparkles: What’s new


:clapper: Get Started


:package: Installation


:bulb: API


:rocket: Examples

Safe Zone

Paint Zone

Coin Spawner

ZUS5xhQ

Voting Pads

WIslioQ

Random Part Generator

f4be5f98a1f9e52e747dbd994b471c98

Ambient Areas

NPC Damager

Sliding Doors


:iphone: Tutorial


Credit

Big thanks to these people for their resources and contributions:


Final

ZonePlus is free and open source! You’re welcome to use and modify this for any of your projects. Credit back to this thread is greatly appreciated although I won’t send the popo after you if you don’t. :policeman:

I won’t be able to respond to all questions, however I pinky-promise that I’ll read your comments. We’ve put hundreds of hours into this resource so its always a joy to hear your feedback!

That’s all amigos, enjoy :pineapple:

1162 Likes
Help with brainstorming a script
Project: Hood - The Crew Clashes Update
How would I check if something is consistently touching something?
Region3 doesn't work
GUI meant for client shows for all players
TTD 3 | Game Credits
TouchEnded fires whenever player is inside of the BasePart
Optimizing region code running on Heartbeat
Zone+ v1 (deprecated) | Retrieving players within an area/zone
How do I count all the players inside a part?
Kit Hub | "The Better ROBLOX Toolbox"
ZonePlus not working when cloned from replicated storage
Checking if a player enters a zone
99% Fail Impossible Obby - Credit
New Part Collision Property: CanTouch [ACTIVATED]
How can I make a tower defense attacking system?
How Would I Make My Coin Script Spawn Random Coins Within A certain Radius?
Detect when a player is in or not in a part
Region3 / GUI Help
How can I fix this damage zone?
How to make irregularly-shaped region detection?
Forcefield gets removed every time I shoot at somnebody in the safezone
Reliable Way to detect when a Player enters a Zone?
Check if 2 parts intersect
Changing Coin UI to fit area player is in
How would I make an elevator TP every players inside it after 5 seconds?
How laggy is while true do
Region3 Support
Detecting Player In a Certain Area Question
Check if player in certain area
How could I possibly get this to work? (Player)
How do I make this not look bad?
How to make a tempature system for your game
How do I make this?
Detecting where a part hits another part
When player leaves the part, tool isn't given
Checking instances inside Region3
Help detect in players in-game region position
How: Simple script to see if a player is inside of a part or touching, part is collision off
PvP Zone not working
About turning a Part into a safe zone
Faster alternative to a .Touched event?
Having issues with making a part that damage you overtime
Having issues with making a part that damage you overtime
How to make a shop circle like in simulators
Making a zone for the player but I can detect it if they are touching it
Detect when a player is in or not in a part
Anti Fly (server side)
Stat Boost Script Not Working
Which method would be most reliable for Touched?
Which method would be most reliable for Touched?
Music Regions Are Lagging My Game
Needing help with region3s playing sounds
I want to detect when the player is inside of a specific part
How to make a selected group of players teleport to a different game
Coroutine vs While True loop or other ideas for a script that runs on proximity
RoPlay - Update Log & Attributions
Effecient Alternative to TouchEnded()?
RPG NPC breaks if there is more than 1
How would I make a maze character
Region3 not responsive
How do you make a player die after time runs out?
Game stops awarding me points at 4 Points thinking that I left the zone even tho I am still in it
"Wait until" code stops entire script
What’s the best way to make an environmental changer?
Welcome to 1867 Historical Role Play
What should I do to recognize the person in the car or motorcycle when touched?
Only one Region3 value is working for some reason
How would I make a zone based gravity system?
Detect if a player is inside a certain area
part.Touched triggering
TTD 3 | Credits & Attributions
How can I get all characters within a part using :GetPartsInPart?
Player/Team Detecting Zone Help
How can I get Coins to spawn in Random Locations
Stopping spawn killers
Tracking Players in zones
Is there any way to improve upon my teleporter system
My value is going negative super fastly
What is the math behind a rank counter?
Audio resets on space bar pressed
How to make a camera that will switch from 2d side scroller view to regular 3d controllable camera depending on the area the player is in
Need help with region music!
Update a Value every second a player is inside a specific part
99% Fail - Updates and Credit
I need help with GUI appearing in a certain zone
How can I know if a player is in a room?
Randomly Spawning Objects Based On Other Parts In A Map
How to seperate a map into different regions/districts, so I can detect what region of a map a player is in?
How can i check if a player is in zone then he is in specific team and if he leave his team change?
How to make a player get 10 damage every 1 secont if he is inside of a part
Everything's going wrong in my game
Dora's Hangout | Credits
What is the most efficient way to tell if a player is in a certain area?
Would this module be considered useful to you?
Region3 issues, not detecting the parts the way I want it to
How I could make damage in area (system)?
Zone System Not Working As Intended
Anti-Gravity room effect not working properly
How can I see if a player is Inside of zone using heartbeat service?
How could i improve my teleporter system
How can I take damage with a tool in limited area only?
How would I make a map border do continuous damage?
Efficient & working way to determine whether the train is in the platform?
Zone API v1.0 is out!
How to play different ambient sound in different areas?
Touched-Ended Event Issues
Area Only Music
Mochi Skills - One Piece Fruit - Open-Source [UPDATED, 2 SKILLS NOW]
How can I make a placement system?
Fairy Emotes | Credits
How would I detect when a player is constantly standing on a platform until they get off it?
How can i create a region like this?
.Touched Collisions don't register
How do I remove gravity from an area of the map?
How would one tell if a player is under water?
Wind Shake: High performance wind effect for leaves and foliage
Monsters of Etheria Attributions
Disable tools in one area
AFK Zone where to earn money every x amount of time
.Touched or a constant :GetPartsBoundInBox()?
How to create terrain water behavior, without terrain water
Question regarding ForeverHD's ZonePlus
How to know if a player is in a part?
How would i get players that entered a zone / left a zone
Need help with creating a fully working button
Location Title - Create Location Title Screens with this Module, Customizable
Finding if a Player is Touching something
Save your player data with ProfileService! (DataStore Module)
Detecting when a player walks off of touched part
How to deal with inconsistent touched events
Alternative to .Touched for fast and responsive stickiness
Best way to make training zones?
How to prevent glitching out of map
Can't find reliable way to get players in specific area
How to make zones
Multiple instances for 1 variable
Else statement breaks the script
How can I make a zone only accessible for certains users?
Making a Detection Script for a Door
Help with Part.Touched and Part.TouchEnded
Stop GUI from flickering
Find player in area
High performance water: Swimmable part 2.0
[VIDEO] Getting Started with ZonePlus - The Best Way to Create Zones And Regions in your Roblox Experience
Help needed with Bugged Water system
Zombie AI Mechanics
How do I make this gui?
Best way to get player character from Region3
Is there any way to create layered lighting?
How would I check if a player entered or left a zone
How would I check if a player entered or left a zone
Change part transparency through raycast
Enemy npc not tracking player
Trying to get parts from a Non-Cubical Area
Exploiter accessing unauthorized area
Detect if player is in certain area
Region3.new Issue
What's the best way to do a King of the Hill style game?
How to make touch and stop touching script
Need help with periodicaly damaging area (utilizing ZonePlus)
Efficiently detecting if a player is touching a part
Zone parts must belong to the 'Default' (0) CollisionGroup (ZoneModule)
ZonePlus not firing it's events after dying
Region3 help youknow how when you enter the region you make something happen how do you make something happen when you exit?
Nothing is working. I cannot get KILLZONE to detect if a part from a character. I've actually tried everything I can think of [SOLVED]
Script doesn't play audio
How to detect how many players are touching a part
How to make biomes with TERRAIN
onTouch not working for my part
Is this possible: Spawn Zone idea, Questions
How do i make a Zone/Region for my attacks?
Ball Magnet In my League
My local script is editing everyone's attributes based on a single person's action
Creating a Temperature System
How to detect player and a part in a region
A better way to check if something is inside a character
How can I make a part spawn randomly like a coin spawner
Having trouble with safezone (solved)
What is the better way to detect If a player enters zones?
What is the better way to detect If a player enters zones?
Output giving me a nil error, even if that's what I want?
Safe zone error
GUI Not Disappearing
How do I add a Cooldown in my script to prevent overlapping?
Touch a part to open a GUI shop
Good Modules to Add
Ready platform glitching out
Zone Trigger Script
Server side verification for client side projectiles or raycast
Need help with dialogue script
What are the best ways to detect a hitbox?
Enable rotating parts only if a player is near them
What is the best alternative for .Touched but not ZonePlus or Raycast hitbox?
Jumping fires a TouchEnded signal for no reason
Script causing fps to drop to 12
Rigged Doors Script
How to have elevator teleport everyone in the elevator
How do I make players slip off each-others heads?
Script burden's server too much for no reason
Collision not detected
ZonePlus fails to work after death
Proximity triggered door spams opening and closing continuously
How do i achieve pitch black room?
How to check if player is inside a part?
How do i detect if player is/isnt inside hollow cylinder?
Handling client-side tweens with streaming enabled
TouchEnded and Touched firing when jumping inside zone
Staying Together 2 Credits
How do I make ambience that changes upon entering different areas?
Need help with AOE Cone
What is the best way to precisely detect a player on top of a model?
Touch and TouchEnded is NOT INTENDED for the creation of enter/leave zones
I used ChatGPT for a specific local script that worked for what I asked -- Is it efficient?
Check if player is in zone
What is the easiest/most efficient way to check if a player is in an area?
How could i check if a item is placed
Merchbooth's shoppable region problem
Limiting Velocity for the Player when touching a Union
Detecting touch efficiently
Help with a fortnite-like storm
How can i detect if a player enteres a zone, note that there are a lot of models
ZonePlus Hitbox Problem
Table not working properly?
How to detect if a part is in a zone or not
Making a part immune to certain effects
Trigger part not working when standing still
.Touched event randomly stops working after 1-2 minutes
Help with detecting players in a specific region
What are you working on currently? (2023)
Entering a safezone makes your time stay the same
How could I achieve Capture Objective / King of The Hill?
Overhead UI Glitching Whilst Touching Part
OverlapParams Forcefield Part
Code issues - Preventing Spam when Saving Player Positions
Oxygen system breaks after player respawns
Run Loop When None Player Left Touching a Part
Different Areas with Different Musics
Exploit Prevention
[REPOST] Creating a player exited event
Detecting when parts move out of a region
Weird Problem with Touched Event & Anchoring
How to make Hardpoint system?
5% of Time/Points Dropped On Leave If Out Of Spawn
How to detect when the whole character stops touching a part
Area music not working properly
How to detect different "zones" in the map
Check if there is anything inside the zone [SPAWN CARS]
Use ZonePlus module for hardpoint system
Problems with stopping a loop (typewriter effect)
Problem with hardpoint system
I can't fix the script on the endurance auto train
Sound Region stops when player takes out a tool
How to make perfect hitbox
Using wind physics to simulate a fan
Help with Hardpoint system
Simple question
Help with finding dummies in certain range
Hitbox or Touched event for detection?
:GetTouchingParts() not working
Enhancing Game Performance with Procedural Generation and Efficient Memory Management
How do I get a list of the players that are touching a part?
How would I check if a Player is in a part (Part.Touched, Region3 or other)
How do i get what parts are touching a part to verify them?
Stop giving currency when player has stopped touching part
Need help with a script
How should I do this? Looping through parts n stuff
Problem in Player Chasing
How to do a while touching loop!
How would I make a part where you can swim in it with custom swimming controlls?
Checking which players are touching a part
Hitboxing on client
How can I make this door stay open if a player is inside a part?
# | best posts - free/paid | #
How to make a temperature system?
Sanguine Fields [BETA] - Credits
How to get .touched to fire when changing its size?
Most preferred / Best Frameworks?
How would I make a script that changes between 2 lighting presets when the character is outdoors v indoors?
Adjusting volume of a sound when touching / inside a part
How Do Games Make Lighting Zones For Different Maps?
Efficiently finding a part at a given position
Quicker Part.Touched Alternative
MouseCastPlus v1 | Easily detect 3D mouse interactions
Sound Region LocalScript
How can I know the distance between two part?
Trouble with regional gui
How to make it so entering and exiting a non collidable part triggers an event
Script wont print
City Tycoon Devlog
How to damage player if he is outside of a part
Tool not equipping/unequipping
Whats the best way to go about region detection?
Why you should use Wally, a package manager for Roblox
Does anyone know how could i implement this to my zombie game?
How would i detect if a item/part is on a plot?
Keep door open if player is still in trigger box
[Kind of completed] HDR effect script similar to Source Engine
Music in a different area
Biome Detection System
Script duplicating Value
Problems with TouchEnded
Issue detecting touched
Disable tool if player isnt within zone
ProximitySignal - Fire an event when the LocalPlayer goes within a certain proximity of a BasePart
How can I make game like a Cities: Skylines?
Code is running poorly
How do you play a sound for the player if they join a team?
How to detect players in a region/zone?
Problem with Finding Parts within a Region3
Is it really possible to build a true open world game (no loading screens between areas) on Roblox?
What would be the best way to figure out if a Player is inside an area(Shape of A Square)?
How would I make a safe zone that wouldn't make you gain any leaderstats?
Fakejeffret Games game Credits
TouchEnded Issue
EasySound - Regional music to all your needs
Store player's tools in ReplicatedStorage
Teleporting many players to CFrame fails for some players
I need help with GUI appearing in a certain zone
Help making a checkpoint system
How would I check if something is consistently touching something?
How to add a tool into the toolbox using script
What is the best way to Implement a Debounce in Region3?
What is the best way to handle touched events in my bomb pass game?
Is it possible for an event to fire when I player enters and leaves a certain region (maybe using region3)?
Correctly Performing Spatial Queries
Help with region3
Trying to create a Safe zone
Invisible part that changes atmosphere density only while touched
Kill all players in a certain area
Tool constantly cloning to character and destroying
Safezone (No tools in certain area & receive out of that area)
How to make a sword fighting area?

Really nice work you’ve done
Keep it up :+1:

35 Likes

This is awesome! I will definitely be using this for my games. Thanks!

27 Likes

Great to see performance optimizations and new features, will definetely updating v1 to v2. Thanks for releasing this!

14 Likes

Fantasic! I am definitly using this to create dynamic lighting zones such as when entering a desert zone or a cave!

Thanks again @ForeverHD

18 Likes

I was definitely pondering about subdividing a world into “zones”, where each zone would have its own environment effects and contextual information, such as a spooky forest with a boss fight.

This resource you shared suggests to me that design is not a bad idea.

16 Likes

I’m pretty new to scripting lua
So I need a bit of help w/ my script if u don’t mind
Basically I want to player to be given a tool once entered. And the tool destroyed once they leave the zone

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local group = workspace.areanas._1.swordzone
local zone = Zone.new(group)
local Players = game:GetService("Players")

local Sword = game.ServerStorage.ClassicSword
local char = Players.Character

zone.partEntered:Connect(function(plr)
	for _,v in pairs(char.Character:GetChildren()) do
		if v.Name == Sword.Name then
			return
		end
	end    
	for _,v in pairs(char.Backpack:GetChildren()) do
		if v.Name == Sword.Name then
			return
		end
	end
	Sword:Clone().Parent = plr.Character
end)

zone.playerExited:Connect(function(plr)
	if not char then return end
	for _,v in pairs(char:GetChildren()) do
		if v.Name == Sword.Name then
			v:Destroy()
		end
	end
	for _,v in pairs(char.Backpack:GetChildren()) do
		if v.Name == Sword.Name then
			v:Destroy()
		end
	end
end)

Character is not a valid member of Players "Players"
Script 'ServerScriptService.Script', Line 7 - local char = Players.Character

I copied and pasted parts of my old zone script a friend of mine made for me so idk if it will still work

13 Likes

Great work! Can i use in my game?

10 Likes

For zonePlus specifically there’s one bug I can see at a glance:

For this scenario you’ll want to use zone.playerEntered instead of partEntered.

For the entire script itself, your code breaks as you’re trying to reference Character for the PlayerService (whereas you can only do this on a player instance), try something like this instead:

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local group = workspace.areanas._1.swordzone
local zone = Zone.new(group)
local swordName = "ClassicSword"
local sword = game:GetService("ServerStorage")[swordName]

zone.playerEntered:Connect(function(plr)
	local char = plr.Character
	local foundSword = char:FindFirstChild(swordName) or plr.Backpack:FindFirstChild(swordName)
	if not foundSword then
		sword:Clone().Parent = plr.Character
	end
end)

zone.playerExited:Connect(function(plr)
	local char = plr.Character
	local foundSword = char:FindFirstChild(swordName) or plr.Backpack:FindFirstChild(swordName)
	if foundSword then
		foundSword:Destroy()
	end
end)
11 Likes

Sure you’re free to use and modify the project in anyway you like - simply provide credit and link back to this thread where possible!

12 Likes

Excellent Work! I am using this awesome module to make a checkpoint system. I have a question! There is any method you already made that can return which “part” player entered?

Like I have few checkpoint C1, C2, C3 etc… in the same folder.
If player entered C3 without entered C2 before. Player checkpoint should still C1. So I think I need to check which “part” player exactly entered.

There is my code I already write I think this would work too.

local checkPointGroup = game.Workspace.Map1.Zones.CheckpointZone:GetChildren()
for _, checkPoint in ipairs(checkPointGroup) do
	local checkpointZone = Zone.new(checkPoint)
	checkpointZone.playerEntered:Connect(function(player)
		print(player.Name .. " Entered " .. checkPoint.Name)
	end)
	
	checkpointZone.playerExited:Connect(function(player)
		print(player.Name .. " Exited " .. checkPoint.Name)
	end)
end

But just wondering is there is a method or other way can return which “part” player entered? Thank you for this awesome module!

8 Likes

When the player enters, you could iterate through it’s character parts and call zone:findPart(basePart) to determine which of its parts are within the zone.

Alternatively you could use the partEntered and partExited events when BasePart.CanTouch goes live.


@Maurity_Dev Sure that’s perfectly fine

7 Likes

No clue why but Zone+ V2 doesnt even work for me, I’ve tried to do a safezone, tampered with it, then went to your original script and used it but it still didn’t work. It could be because I put the spawn into the safezone?

9 Likes

Great job with the update and optimizations :+1:

Just updated and logged it into my patch notes for my game’s next major update.

9 Likes

v2 isn’t backwards compatible with v1 (due to the new optimisations which require a different API) therefore if you’re using code from v1 this is likely why.

It’s also important to note that the additionalHeight parameter has been removed, therefore the group-parts that make up the zone have to encapsulate the entire area of the zone.

You can view coded examples for v2 at the new playground, including a safe zone example, and for more information you can visit the docs.

7 Likes

I have V2 but I didn’t remember to remove additionalHeight, thank you so much for getting a quick response. Honestly, I enjoy zone+ V2, good job making it.

5 Likes

Hello, just want to let you know that the link for the API takes you to “https://1foreverhd.github.io/ZonePlus/zone/”, which is an Error 404, instead of “Zone - ZonePlus”.

5 Likes

Quick question;

Whenever I click play, both in Studio and in real servers, the descendant BaseParts of my ZoneGroup get destroyed. Do you know of a solution to this issue?
There are no other scripts in the game at all, and it’s currently just meshes and baseparts in the game.

My script is as follows:

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local zoneGroup = workspace.LobbyZoneGroup
local zone = Zone.new(zoneGroup)

zone.localPlayerEntered:Connect(function()
	PlayThing()
end)

The ZoneGroup is as follows:
75fc3e91dc343a30957775c8687cb040

4 Likes

ZonePlus shouldn’t be destroying any descendant baseparts. Can you provide a video showing the workspace before and after, or DM me a stripped-down place file with the zone where parts are being destroyed.

4 Likes

This dude is doing the impossible! Keep up the good work :smiley:

4 Likes