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

Show that you’re doing it in a local script, and show the properties of the brick inside. You need CanQuery true

2 Likes

is deleting the parts of a zone safe on memory or do I have to make the zone nil too?
I can still print the actual zone after deleting its parts and even disconnecting it

Is there a way I can dynamically remove and add parts from a zone? For example, I have a table of parts that will constantly have values removed/added from them:

local parts = {workspace.Part1} -- workspace.Part1 will successfully print "part detected"
local zone = zones.new(parts)
zone.localPlayerEntered:Connect(function()
    print('"part detected"')
end)
foo.Event:Connect(function(bar)
    table.insert(parts, bar) -- `bar` will not print out "part detected"
end)

EDIT 1
So in order for the module to consider newly inserted parts in the table, I had to call zone:_update() immediately after inserting/removing a part. This is clearly a hacky method the API doesn’t have this method, but it will do for now.

local parts = {workspace.Part1} -- workspace.Part1 will successfully print "part detected"
local zone = zones.new(parts)
zone.localPlayerEntered:Connect(function()
    print('"part detected"')
end)
foo.Event:Connect(function(bar)
    table.insert(parts, bar) -- `bar` will now print out "part detected"! yay!
    zone:_update()
end)

Hello, is there any way I can make this module work with collision groups. I have a collision group with pets that do not collide with each other, and I want to know if any points enter the zone. If there is no way for the module to do that, are there any other methods to enable me to do so? Thank you!

1 Like

Hey quick question:
Does the zone automatically get removed when the container is destroyed? Or do I have to manually destroy it myself?

1 Like

In pairs does not seem to work for me. Been messing with it for a few hours, still can’t figure it out… In the video below, notice keep an eye out for where it says “Entered” & “left” zone so you can see which zones are calculated.

Here is my code:

local LocationCD = false

function ReloadLocationCD()
	LocationCD = true
	wait(0.3)
	LocationCD = false
end


for _, group in pairs(game.Workspace.LocationParts:GetChildren()) do
	local zone = ZoneM.new(group)
	zone.localPlayerEntered:Connect(function()
		warn("entered a zone")
		if LocationCD == false then
			script.Parent.Thought.Thought.Event:Fire(".. " .. group.Name .. " ..")
			AtmosphereModule:ChangeLocation(group.Name)
			ReloadLocationCD()
		end
	end)
	
	zone.localPlayerExited:Connect(function()
		warn("left a zone")
		if LocationCD == false then
			AtmosphereModule:ChangeLocation("global")
			ReloadLocationCD()
		end
	end)
	
end

Can you maybe add the group.Name to the warn, so we can see better what’s happening and where?

been a long time user of this module, its just great! Recently trying to use this in an obby game and I have notice that zones dont fire event unless the HumanoidRootPart of the character enters the zone.

I did a quick test where only the feet of the character touch the zone, and the events dont fire. I seem to remember this module was able to detect partial parts of a players character, am I remembering things wrong?

ALSO: The API section of the docs site is empty, theres nothing in there. Introduction - ZonePlus

1 Like

Yo I got a question. Is there a way to get the specific part collided with to fire zone.playerEntered? For example, lets say I have parts inside of a folder, which don’t combine to create a new region but they are spread out across an area, but they all have the same function, just runs the code in different areas. How can I get that specific part the player ran into? Great module btw I use it a lot <3

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