This method only accounts for rectangular shapes, therefore is only effective for square-like zones.
There’s this strange behavior when parts overlap or are located in a certain way under others.
This is an awesome module, i really needed this, i was a bit scared of using it because i thought it was something very hard to use, however, i was wrong, it’s very easy to use and useful for alot of stuff, well, i got a small problem:
I already have readed the API i needed for my code, and i don’t know if i wrote something correctly, this code that i have is a vote system, in summary, this would be a loop creating and destroying a zone:
While true do ... for MapNumber, Map in pairs(ChoosenMaps) do --Three times creates a Zone local VoteZone = game.Workspace:FindFirstChild("Zone"..MapNumber) --Gets the zone model local Zone = ZoneService:createZone("Vote"..MapNumber, VoteZone, 15) --Creates the zone --// More code would be here :P //-- Zone:initLoop() VoteEnded:GetPropertyChangedSignal("Value"):Connect(function() if VoteEnded.Value then --It actually changes Zone:endLoop() --The loop ends Zone:destroy() --The zone created gets destroyed end end) end ... wait(10) end
However, when the code gets repeated (because of the While true do), i get the error mentioning that the first Zone created already exists, when i already have deleted it. I don’t know if i wrote something not correctly, if it’s a bug, or if everything is ok with the module so i can fix my code, thanks for reading
When you create a zone via the ZoneService (i.e.
ZoneService:createZone(name, group) it must also be removed via the ZoneService (i.e.
Since you’re creating and destroying lots of zones, and don’t need to reference it outside your section of code, you’re better of directly constructing a zone via the Zone object (instead of using the ZoneService), so now your code can look like:
local ZonePlus = require(4664437268) -- Initiate Zone+ local Zone = require(ZonePlus.Zone) While true do ... for MapNumber, Map in pairs(ChoosenMaps) do --Three times creates a Zone local group = game.Workspace:FindFirstChild("Zone"..MapNumber) --Gets the zone model local zone = Zone.new(group, 15) --Creates the zone --// More code would be here :P //-- zone:initLoop() VoteEnded:GetPropertyChangedSignal("Value"):Connect(function() if VoteEnded.Value then --It actually changes zone:destroy() --The zone created gets destroyed (zone:destroy() calls endZone for you) end end) end ... wait(10) end
You might be able to upgrade Zone+ by utilizing this information:
You might want to consider using TouchEvents now that we know how to make it reliable
Zone+ is primarily intended for server-side use (explained here: https://github.com/1ForeverHD/HDAdmin/issues/30), as apposed to that proposed method which can only function client-sided.
I have a question is there way i can update zone or it already updates? For example i have a folder and there 0 objects i created zone and then i added some parts in folder. will these parts be counted to zone or i need update zone? If i need to update zone how i can do it?
Zones are dynamic; they listen for changes in children (i.e. the adding or removing of a part) and the resizing and positioning of these children. So yep, if you’re adding some parts to its folder, the zone will automatically update for you
Oh also is there way i can detect which part player touching? I want to use it to detect when player near npc and to know near what npc are player near i used ObjectValue inside parts.
You can achieve this with zone:getPlayer(player) which returns the part a player is standing on or within, and its intersection vector:
Zone+ now supports client-use!
Originally Zone+ was intended only for server-use, however many developers had been abusing its functionality for the client (explained in more detail here: https://github.com/1ForeverHD/HDAdmin/issues/30)
To solve this, we’ve modified the behaviour of
zone:getPlayers(), and introduced a new method:
zone:initClientLoop()- for when you only need to check the localplayer (and not every player in the server)
New Ambient Areas example:
Easily play sounds within designated areas (source code found within StarterPlayerScripts in the Zone+ Playground).
Important (if you previously used Zone+ on the client)
If you have previously been using Zone+ on the client, make sure to update your events section to call
zone:initClientLoop() instead of
zone:initLoop(). This significantly improves performance as redundant Region3 checks are completely ignored, and a raycast is only fired for the local player, as apposed to every player within the zones rough-area.
Can you explain on how to make this Zone+ for a gamepass only Zone. I have little understanding when it comes down to this kind of scripting. For instance, where do I put in ID of gamepass? How big can Zone be?
Setup a dictionary which will be used to record who in a server has the gamepass.
When a player joins the server, use UserOwnsGamePassAsync to verify they own the gamepass, and add them to the dictionary if they do.
Setup PromptGamePassPurchaseFinished to check for when a gamepass is purchased. If the gamepass matches your desired gamepass, add them to the dictionary.
zone.playerAddedevent to check for when a player enters your exclusive zone. If they are not within the dictionary previously defined, remove or block them from the zone (e.g. teleport away, kill, etc). You can find more about setting up zones here: https://1foreverhd.github.io/HDAdmin/projects/zoneplus/about/#example-server-sided
I have small experience when it comes to scripting. For step 1, how would I setup a dictionary? Also, when setting this up which script would it go into out of these 3?
For instance would I have to add the Marketplaceservice script myself or is it already added?
echt geil, werde ich in zukunft mal gebrauchen können !!!
I notice the code uses GetTouchingParts, would this not be making your code a little outside server use? I believe you create a Touched event to make GetTouchingParts to work so it could create a server side risk even if it only supports the rest of the module.
Or maybe I am mistaken or was seeing an outdated version.
Hey dude @ForeverHD!
Roblox added a new feature New RaycastParams Property, Deprecating Old Raycast Functions
You should definitely update the module~
GetTouchingParts is used to form ‘clusters’ within a zone when its constructed, not to detect players/parts within that zone. While not necessary, clusters provide more precise sub-areas within a zone, which enables more efficient point generation using getRandomPoint(). Touched events aren’t used alongside GetTouchingParts for this. The cluster system may be removed entirely going forwards as I explore further ways to generate random points.
You can learn more about tables, dictionaries and arrays here, and can view coded examples of Zone+ here. For everything else, I recommend becoming more familiar with lua and the Roblox API and asking further questions within Help and Feedback.