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

Your modules are such a simple idea but are always SO helpful! Thank you for this!

1 Like

Hi i tried making a while loop when u enter the zone but i couldnt make it to stop with exit. do u have any idea how can i make that work? i tried number and bool values from character but they didnt work. and i tried things like while _G.active == true do but they didnt worked. And yes i did change the values before the loop and at the exit script. i also tried some stuff with Zone:FindPlayer but they also didnt worked.

how can i make a loop work only if player is in the zone. as a server script.

Run the loop when they enter the zone with a if true condition (if they are in the zone, do it)

this is the script im using

zone.playerEntered:Connect(function(player)	
	print("player has entered the zone")
	local isWithinZoneBool = icebath:findPlayer(player)
	local health = game.Workspace:WaitForChild(player.Name).Humanoid
	local debounce = game.Workspace[player.Name].bt.icebath
	debounce = 0
	if debounce == 0 and isWithinZoneBool then repeat 
		health.Health -= 15
			debounce = 1
			wait(1) 
			debounce = 0
		until not isWithinZoneBool 
	end
end)

and its not ending the loop when player exits

Hey there, the reason that’s happening is because zone:findPlayer() is always true since it’s only being checked once upon player entrance and not throughout the loop.

This works:

zone.playerEntered:Connect(function(player)
	print("player has entered the zone")
	local health = player.Character.Humanoid
	local debounce = true
	if debounce and icebath:findPlayer(player) then repeat 
			player.Character.Humanoid.Health -= 15
			debounce = false
			wait(1) 
			debounce = true
		until not icebath:findPlayer(player)  
	end
end)

I don’t know why you are checking a seperate zone named icebath though, do you have a zone within a zone? Also I’d advise against using repeat until.

1 Like

icebath is name of the model which has the zone seperately and the parts in it separately.

I was also wondering this, I do not think so but I hope there is a way.

OH I actually ended up testing it for myself and yes it does! The zone can be moved at runtime.

Hey, I have a zone made of an array consisting of baseparts. Problem is, I keep getting a exhausted execution time error when I try to get a random point.

Is this normal?

EDIT: My bad, I had a framework which destroyed the parts with no collisions on.

Zone not working sometimes when I clone it from ServerStorage to workspace. It works 50/50 and sometimes not working for no reason. No errors in output. It create zone but playerEntered event not working.

Not sure that’s how you’re supposed to be doing it, wait for it to be in workspace first and then zone it.

1 Like

Anyone know a solution for this ?
Zone detection only works for the developer of the game. Never detects any other player.

local zone = Zone.new(game.workspace.Part)
zone.playerEntered:Connect(function(pl) --Even works only for the owner / developer of the game. Or for only me. It doesn't work on any other player.
end)

Lets say this is in a Local script. zone.playerEntered fires only on this account and not any other accounts / players.

That’s cause it’s in a Local script.

1 Like

Again.

local zone = Zone.new(game.workspace.Part)
zone.playerEntered:Connect(function(pl) --Even works only for the owner / developer of the game. Or for only me. It doesn't work on any other player.
end)

Thats a local script. If I play the game from roblox on account “ShokuTakahashi”. the playerEvent will fire and work fine. But if i login and play the game from a different account named for example “Eric”. It never fires. No matter if its local or server script.

try adding a print

This module will work in server/client.

I did. It does nothing.

local zone = Zone.new(game.workspace.Part)
zone.playerEntered:Connect(function(pl) --Even works only for the owner / developer of the game. Or for only me. It doesn't work on any other player.
print("Hello")
end)

prints nothing on other accounts.
Prints hello on ShokuTakahashi account. Which is the owner of the game.

Ik but it works differently on the client and server.

I think its something about the experience it self but Idk what its. This is the test that I’ve done.

I created another experience to test in it. With 2 accounts as well. Creator and normal player.

In original game. The script prints only if you play with the creator’s account. Prints nothing on normal player.

In the test game. Script prints perfectly on both accounts.

This is the script. Local script located inside StarterPlayerScripts.

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = workspace.Part
local zone = Zone.new(container)

zone.playerEntered:Connect(function(player)
	print(("%s entered the zone!"):format(player.Name))
end)

zone.playerExited:Connect(function(player)
	print(("%s exited the zone!"):format(player.Name))
end)