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

I’m having great trouble attempting to get the zones to work after the player respawns. I have these safe zones for the player when they spawn, and if they exit them they should go away. They do. However, when the player respawns, the playerEntered and playerExit events literally don’t fire. Here is my localscript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local Zone = require(ReplicatedStorage:WaitForChild("Zone"))
local ZoneEvent = ReplicatedStorage:WaitForChild("ZoneEvent")
local container = workspace:WaitForChild("SafeZone")

local zone = Zone.new(container)

ZoneEvent.OnClientEvent:Connect(function()
	print("fired")

	local childReferences = {}
	local canEnter = true

	for _, child in ipairs(container:GetChildren()) do
		child.Transparency = 1
		childReferences[child] = true

		local zone = Zone.new(child)

		zone.playerEntered:Connect(function(player)
			if canEnter then
				child.Transparency = 0.5
			end
		end)

		zone.playerExited:Connect(function(player)
			canEnter = false

			local transparencyTween = TweenService:Create(child, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1}, true)
			transparencyTween:Play()
		end)
	end
end)

And here is my serverscript for firing the event:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local ZoneEvent = ReplicatedStorage:WaitForChild("ZoneEvent")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		ZoneEvent:FireClient(player)
	end)
end)

Help is appreciated.

Seems like the Roblox model link to ZonePlus is taken down. Is there a new link to it?

You set canEnter to false when the player leaves the zone, but you never set it back to true, so the condition to set the transparency will never pass. You should just remove this variable as it serves no use.

1 Like

Well, I made this variable so that when the player re-enters the zone, the effects aren’t applied. I made it so when you walk out of the zone, it goes away.

why does zone.localPlayerExited fire when dying in the zone and then respawning outside of the zone? This really messes up my script.

Be a better scripter then and account for it?

2 Likes

Is there a way to give priority to zones? So if its higher, they will be activated before other zone thats at the same area.

1 Like

You will need to cache the zone and check if the player is in the priority 1 zone before or not.

Hello, what’s the optimal amount of zones recommended for performance? (client) because in my game i wanna have zones for each EggStand, and I was wondering if there is a recommended max limit number for zones.

Since i wanna check if player entered the Stand’s Hitbox then pop ui else pop ui off

1 Like

It would seem the model on the Roblox website returns a Bad Request.

can’t access the model, it says bad request

2 Likes

Either get it from the uncopylocked place, or get it from the creator marketplace

1 Like

Wow, this is amazing! This really helped me out on my first simulator game. Thank you so much :hearts: :hearts:

1 Like

constantly getting errors about calling a nil value
even made a completely fresh game and put in a simple script and still not working
anyone else getting this problem?

2 Likes

hey, so even though im calling the module from a local script, it seems to replicate to the server. is there a way to prevent this?

That’s not even a thing? Show your code and usage.

1 Like

It’s fine, I ended up just going a different path. Not sure why it was happening, probably something was replicated to the server.

Hi! How would I detect the exact name of the zone part that a player has entered inside a container? For example, I have a container with 10 safezones in it all named safezone1, safezone2, etc. I want “safezone7” to be printed out, but I can’t find any API for that.

Hey, you can get the parts the player is touching with:

local touchingZonesArray, touchingPartsDictionary = ZoneController.getTouchingZones(player)

The parts are within touchingPartsDictionary.

If you need to listen for players entering/exiting these parts, you would make every part into it’s own zone. Creating more zones adds minimal-to-no additional impact to performance.

1 Like

Wonderful, thank you for the insight was avoiding the solution you gave because I thought it would impact performance, great to know it doesn’t!