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

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

Hello! So I’m trying to make zones to change the lighting when entered. But when I enter the Zone, nothing happens. I’m probably doing something wrong. here is my code:

It’s a local script.


local ZonePlus = require(game.ReplicatedStorage.Zone)
local Zone = ZonePlus.new(script.Parent)

local LightModes = require(game.ReplicatedStorage.LightModes)

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

Zone:bindToGroup("LightingGroup")

Zone.itemEntered:Connect(function()

	LightModes:SetMode("MorningSun")

end)

Zone:track(Char)


Need to be using LocalPlayerEntered
snippet from my work:

local zone = Zone.new(group)
	zone:bindToGroup('SectionZones')
	zone:setDetection("Centre")
	zone.localPlayerExited:Connect(function()
		activeZones = activeZones-1
		print(activeZones)
		if activeZones == 0 then
			changeLighting(Lighting.Outside)
		end
	end)
	zone.localPlayerEntered:Connect(function()
		activeZones = activeZones+1
		if Lighting[group.Name] then
			changeLighting( Lighting[group.Name] )
		end
	end)
3 Likes

Ah thanks. I didn’t realize there was a different event for local scripts. Lol

1 Like

This is so good Roblox should hire you to include it natively into Roblox Studio, very usefull, most likely every game made in Roblox soon or later will need some kind of zone checking making devs most of the times use poorly made checking without proper performance. With your module developers get it for free, with good performance and very easy to use. Congrats on your great work!

1 Like

Did you ever find out what the issue was? Looked at the github and dont see any updates.

This is really awesome. One thing though, I’m creating like a spatial audio type of thing as presented in one of the examples. The problem is that I have some parts inside of the zone that contains SurfaceGUIs with buttons on them. The button events won’t be registered as the zone is in the way.

Trying CanQuery actually works, but then completely disables the zone.
Any recommendations on how to solve this problem?

I’m just waiting back on this bug report then plan to continue exploring your issue:

2 Likes

zone:relocate() should do the trick!

3 Likes

I’m having problems with using the :getParts() function. For some reason, it still returns parts that were inside the region, but are not anymore, until those parts move again.

Essentially, if a player enters using partEntered and then leaves using partExited, the :getParts() method still returns the parts of the player even though they are nowhere near the zone. partEntered and partExited still work as intended however, which is odd. If i return the part provided by partExited, it very clearly provides parts of the player that aren’t in the zone anymore. getParts(), on the other hand, says thay are still inside.

In this example, the baseplate turns green when parts are inside the zone, and red when there are none. I walked into the zone (transparent pink part) and it turned green but walking out did not turn red:


I’m printing the results of getParts() and the bodyparts are still being returned when they shouldn’t:
image

As soon as i then move, it realises the parts aren’t in the zone anymore:

Please excuse my bad code here, I was trying to see if it was just partEntered being fired after the last part left or something by constantly checking for parts until there are none anymore:

Essentially, when a part enters the zone, it starts a runservice loop that checks for parts using getParts() until the number of parts returned is 0, where the connection is terminated and the zone waits for a new part before repeating.
I know this is a terrible solution but i was just trying to work out if it was my implementation or if it was the zone module having issues. It appears to be the latter.

(SharedFunctions:IsTagged() is just a checker for parts that are tagged. All parts of the player are tagged correctly so this isn’t causing the problem. Same results happen with that omitted)

Any help appreciated!

Edit: The Zone is just being made with that transparent pink part, a normal brick, from this line: