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

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

2 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

How can I check if a Humanoid entered the zone? Like not a player, but an NPC?

There is a big issue where ZonePlus stops working and thats if you got around 24 listeners for PlayerExited, PlayerEntered, ItemExited and ItemEntered

So basically this connection won’t work if there are too many connections that listen for any of the things I put above.

local zone = ZONE_MOD.new
zone(WS.Game.DoorZones.DoorRoom1.Hitbox).playerEntered:Connect(function(player)
print(player)
end)
1 Like

Read the documentation man, you’ll find it there:

It’s “partEntered”

1 Like

How would I control the volume of audio?
To make it ease in and ease out when entering and exiting a zone

For some reason, the ambient music doesn’t work for terrain maps?

Your best bet is doing zone:trackItem(NPCHumanoid) then using the itemEntered and itemExited events to listen for changes.

2 Likes

If you have time, can you link me to an uncopylocked place which reproduces this issue. This would be super helpful in exploring it further.

1 Like

You can find an open source example of that at the playground:

3 Likes

Try walking between the rooms and you’ll see some exited or some entered don’t fire,

1 Like

Is this module still usable for new work?

Yep ZonePlus is actively maintained :+1:

You can track its changes and to-do list at the repository:

3 Likes