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

Thank you soo much I was thinking about creating something like this last night in the shower

it says the table index is nil on line 68. So the table reference is missing. as if to say it was never added in the first place

Hello everyone,

I’m stucked with an issue on collision (I guess) with ZonePlus. I can’t clearly debug. Everything seems to be normal from the code logic, but actually something triggers multiple times.

I am creating a zone in server script attached to the part, detecting players enetering and exiting:

local Zone = require(game:GetService("ReplicatedStorage").Zone)
local container = script.Parent
local zone = Zone.new(container)
zone:setAccuracy("Precise")
zone:setDetection("WholeBody")

local ServerScriptService = game:GetService("ServerScriptService")

-- ADD BINDABLE EVENTS FOR SERVER
local Open = ServerScriptService.BindableEvents:WaitForChild("Open")
local Close= ServerScriptService.BindableEvents:WaitForChild("Close")


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

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

The script triggers a bindable event that activates another server script that takes care of handling a timer for the specific user. The problem here is that, I don’t understand why, the while loop seems to be triggered multiple times, athough I can’t clearly intercept multiple fires. The print(“Times”) runs more than once per second. The problem happens when you walk close by the bounds of the zone.

local ServerScriptService = game:GetService("ServerScriptService")
local Open = ServerScriptService.BindableEvents:WaitForChild("Open")
local Close = ServerScriptService.BindableEvents:WaitForChild("Close")

local ON = {}

local function processOpenPlayingSessionEvent(player)
	ON[player] = true

	-- SESSION MANAGER
	while ON[player] == true do
		print("Time")
        -- do stuff while ON
		wait(1)
	end
end

local function processClosePlayingSessionEvent(player)
	ON[player] = false
end

Open.Event:Connect(processOpenPlayingSessionEvent)
Close.Event:Connect(processClosePlayingSessionEvent)

Can someone please give it a hint? Would be really appreciated. Stucked here for days…

does regions zones can be custom shapes? like the zones can be cylinders or triangular prisms or others.

Might I start by saying I love this API, it has made region-based scripts so much easier for me. But I need help. How can I get the info of the region that a player enters in? I want a gui to display the name of the part that the player enters, as well as being able to get a string within the part’s children. Here’s the snippet of code from my script.

-- Zone Controller
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Zone = require(ReplicatedStorage.Zone)
local ZoneController = require(ReplicatedStorage.Zone.ZoneController)

-- Containers
local AncestorContainer = workspace.EnvironmentTriggers -- Makes up all the regions within the folder

-- Zone Variables
local ZoneVar = Zone.new(AncestorContainer)
local localPlayer = game.Players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")


ZoneVar.playerEntered:Connect(function(playerWhoEntered) -- Fire script when they enter
	
	playerGui.RegionGUI.Background.Title.Text = ZoneVar:WaitForChild()
	playerGui.RegionGUI.Background.Subtitle.Text = "Adventure Awaits!"

I have a bug where i’m inside a zone and when i run into random parts inside of that zone then sometimes it registers that i’ve left the zone… does anyone have a fix for this?

Just want to report a bug that occurs when applying using

humanoid:ApplyDescription()

The player is no longer detected by a zone after applying a new humanoid description to a player.

Is there anyone else experiencing this?

2 Likes

@ForeverHD
Pull Request - Update Enum

It’s only me that I’m getting acess denied to get the model or even the public acess game?

4 Likes

anyone else getting Bad Request while trying to get the model?

1 Like

If a zone is deleted, will it delete the zone related to it, want to use this for a tycoon, but purchases can be removed so gotta be careful not to cause memory leaks.

You will need to grab it off the github.

1 Like

Learn how to script then, not hard to start.

1 Like

I came to this forum for help with the script itself.

I’m pretty sure the zones are connected to the part you set them to. I tested it myself, and it stopped printing “player entered” when the zone part was deleted.

but are the zones and their events properly garbage collected

Regarding if they will free up memory or not, I believe it does but you’ll have to check with the documentation and API. Considering its made by ForeverHD, i’d assume he has accounted for that.

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