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

This ability hasn’t been added yet, has it? I see you closed the issue on github but there aren’t any updates.
I have a problem like OP’s where using a workspace part breaks some things. I’ve read that maybe I can use replicated storage zones if I put them within WorldModels? I suppose I’ll experiment with that solution if this isn’t a native ability yet.

Is there any way to detect if a player is already within a zone?
e.g. dialogue boxes starting when you’re within a radius, and exiting when you’re out of a radius.

local isWithinZoneBool = zone:findLocalPlayer()
2 Likes

Can you use the same “container” part for multiple zones? I can’t find anything in the documentation about it but I believe doing that is what’s been making my code break.

If I’m blind and it clearly states that somewhere please don’t be mad at me.

Nice module, useful for a heckton of things outside of hitboxes.

1 Like

Great module. But does it have spherical detection?

1 Like

By the looks of it, it appears to even have cone shaped zones so I’m sure it will also have spheres :+1:

1 Like

localPlayerEntered doesnt seem to work when you reset while in the part?

What tags are given to zones? Right now I have a raycast gun that keeps hitting the zone and would like to use collection service to get all zones and filter them out.

Hello! Thanks alot for publishing this module, really helps my game a ton! One issue though, since i’m dealing with datastores and saving furnitures/rooms is a must, when i construct a new zone on a local script after the rooms are loaded by the datastores, the zones sometimes don’t work. Any ideas on what’s causing this? I did waitforchild already, and i made sure the collection service got loaded in so the bug must have happened during the beginning of the game session. P.S. I narrowed down where the problem is located, it seems that when you construct a zone for the rooms’ main building model, the detection system somewhat goes haywire. In conclusion, I believe there are problems when the zones overlap each other

Hello, I have read the API, but I still don’t know if I could take a part from replicated storage, then clone it to workspace, is there any function or anything to update the part?

not relocate

A script clones a part from replicated storage to workspace and after some time it gets destroyed, how would I add an event for that and then update the container?

NVM I realised the way of adding it to the folder was the key

1 Like

By default, every 0.1 interval, although this behaviour can be customised with setAccuracy:

You can use the itemEntered and itemExited events and zone:trackItem to track seats.

This is a typo, thanks for the feedback! I’ll have this fixed.

For our next update we’ll have zones automatically destroy/cleanup themselves if their container/descendants are completely destroyed, however for the time being you must ensure you’re calling zone:destroy()

Not currently, it’s something we are exploring, although it’s not straightforward unfortunately due to how spatial queries work, and due to the collaborative nature of zones.

For our next update we’ll have zones automatically destroy/cleanup themselves if their container/descendants are completely destroyed, however for the time being you must ensure you’re calling zone:destroy()

We swapped the default behaviour from WholeBody checks to just a Central HRP check. If you’d like to swap back you can do:

zone:setDetection("WholeBody")

This appears to be working fine, you can you provide more info?

zone:relocate()

You should be able to although lemme know if you run into any issues with this.

Yes, ZonePlus supports virtually all geometries.

Call zone:relocate() to move the zone parts from Workspace into a WorldModel in Replicated/ServerStorage.

3 Likes

I really hope the automatic deletion of zones via the part and such deleting update will come soon. I currently use this with loading in parts and despawning them and the zones stick around because the parts are based on modules so it’s impossible to delete the zones manually.

1 Like

We’ll likely cluster all the current to-do’s into one large update to save us time, so I imagine not for a while as we work towards releasing further open source projects.

If you add the following code under line 120 of the Zone module this should do the trick:

-- This ensures the zone object is destroyed if its associated container is destroyed
if containerType == "Instance" then
	container.AncestryChanged:Connect(function()
		if not container:IsDescendantOf(game) then
			self:destroy()
		end
	end)
end
2 Likes

For some odd reason, if the player is killed or resets, if the player touches a zone after it, they don’t detect it.

local Zone = require(game:GetService("ReplicatedStorage").Zone)


local Zones = workspace:WaitForChild("Areas") -- This is a folder
local Shop = Zone.new(Zones.ShopAreas) -- then these are also folders with all of the area parts
local Caves = Zone.new(Zones.CaveAreas)

Shop.playerEntered:Connect(function(player) -- shop connect
	print(player.Name.." entered the zone!!")
end)

Shop.playerExited:Connect(function(player) -- shop disconnect
	print(player.Name.." exited the zone!!")
end)

Caves.playerEntered:Connect(function(player) -- cave connect
	print(player.Name.." entered the zone!!")
end)

Caves.playerExited:Connect(function(player) -- cave disconnect
	print(player.Name.." exited the zone!!")
end)

This is for a local area music system, it is a local script inside of the StarterGui

1 Like

I can’t seem to reproduce this.

First off, what version of ZonePlus are you using?
image

Secondly, are you sure you want to be using playerEntered and playerExited instead of localPlayerEntered and localPlayerExited (which check only the client’s character, instead of everyones)?

If the issue persists, can you provide further details such as videos and images of the issue, snapshots of the console, etc.

2 Likes

I am using Version 3.2.0

I tried localPlayerEntered and Exited with no luck, now it errors right after the player dies, and doesn’t work still.

I also lose my leave print.

Code –


local Zone = require(game:GetService("ReplicatedStorage").Zone)


local Zones = workspace:WaitForChild("Areas")
local Shop = Zone.new(Zones.ShopAreas)
local Caves = Zone.new(Zones.CaveAreas)

Shop.localPlayerEntered:Connect(function(player)
	print(player.Name.." entered the zone!!")
end)

Shop.localplayerExited:Connect(function(player)
	print(player.Name.." exited the zone!!")
end)

Caves.localplayerEntered:Connect(function(player)
	print(player.Name.." entered the zone!!")
end)

Caves.localplayerExited:Connect(function(player)
	print(player.Name.." exited the zone!!")
end)

If you want i dumped all of the parts into a .rbxl if you want to look at it.
LocalAreaMusic.rbxl (69.4 KB)

Your LocalScript ‘Controller’ needs to be located within StarterPlayerScripts instead of StarterGui so that it doesn’t reset on spawn:

image

Also make sure to correct localplayerEntered to localPlayerEntered

3 Likes

@ForeverHD Hey, Ben I really love your work. But, I’ve noticed a new problem. It seems like Roblox has released a new property called “CanQuery” and if you turn it off on the part that was used as a container for Zone, it will not work. Could you please update it to output the error when we turn off “CanQuery”?

1 Like

Thanks for the suggestion, we’ll introduce a warning for that in the next release:

3 Likes