Amazinngggg!!! Super useful for me, thank you!!
Impressive. This might be a new way to create hitboxes but I guess I have to try it out for myself.
Iâm really confused about the return value of :getPlayers. I printed the key and value of the table returned, and I expected 1 and my username (concatenating instance results in instance name), however I got two values, which resulted in an error in my code?
Can this be elaborated on?
When I enable the EventsExample script in the example place, it just keeps printing âPlayer Entered zone: SafeZoneâ when I am in the Zone in a loop and then prints nothing when I leave the zone. Is this meant to happen?
Hello HD Team,
Good job! Should I keep an eye on the git repo for updates, or do you also regularly update the https://www.roblox.com/library/4664437268/Zone asset so that I can simply require it?
Thanks and best regards
The function may return only a true, but not a false. This leads to an error in my use case.
My Use Case
print("Is in safezone? " .. tostring(newZone:getPlayer(player)))
Your Function
function Zone:getPlayer(player)
local char = player.Character
local hrp = char and char:FindFirstChild("HumanoidRootPart")
if hrp then
local origin = hrp.Position + Vector3.new(0, 4, 0)
local lookDirection = origin + Vector3.new(0, -1, 0)
local ray = Ray.new(origin, (lookDirection - origin).unit * (self.RegionHeight))
local groupPart = workspace:FindPartOnRayWithWhitelist(ray, self.GroupParts)
if groupPart then
return true
end
end
end
The fix is quite simple, just insert a return false in the last line.
@Abbaok_origin For the time being, I recommend using the repository to get the most up-to-date code as thatâs actively maintained. Down the line, Iâm looking to automatically update the module with the repositoryâs code, so youâre more than welcome to do so without issue then. Iâll post a follow-up message here once thatâs ready.
@LukasImWeb
Added, thanks for the suggestion
Hello Forever,
I really like this module and have now integrated it into my simulator to create safezones and a zone where bossfights can take place. I also want to drop gems in certain areas and it would be nice to have a function to get a random vec3 point in a zone. Even if the zone consists of several different, unconnected parts. Iâm going to solve this issue differently for now, but maybe this would be a feature for future functions of your module.
Hello Forever,
I have another suggestion for improving your module. I have areas in my future simulator which the players have to unlock. I have created large >local< parts around these areas (by local cloning of already existing invisible âserverâ parts).I think this os more convenient than collision group. Hackers could simply delete these local parts and have access to the actually locked areas. At the same time I have created these barriers on the server as transparent âserver partsâ. These are a zone where your event zone.playerAdded listens to. It would be great if you could add an event which is triggered as soon as a player is completely in a zone. I was planning to kill hackers who delete the local parts and go into the zone. Unfortunately, PlayerAdded is already triggered when you touch the outer skin of the zone. This also kills all players who donât hack and just collide with the outer skin as intended.
Greetings and good work so far!
Hi Abbaok, is this something youâre unable to achieve by creating a secondary zone of your smaller desired area, then listening for playerAdded
with this?
Hello Forever,
I had the same idea at first. Iâm glad you also had the same idea. I donât find it elegant in code to do this myself. Currently I do it, but that would be a feature you could include if you want to. All you have to do is clone zone parts and scale them down by X% and then you have to listen to the playerAdded, which triggers the new event playerEnteredCompletlyZone (or something like that) in the Parent Zone.
greetings
This is literally the smartest method Iâve ever seen, Iâve been roughly trying to find some methods to check if a player is in a certain zone without making too many checks and without checking it on the client, your post saved my entire developer career!
This doesnât appear to work with a single part. Is there a way to fix this?
A quick test on single blocks and cylinders appears to work. Are you able to provide more details on reproducing the bug? https://i.gyazo.com/4902bff13e60aa23cdeb52bd20019910.gif
I was referring to boundaries. Iâm working on a king of the hill system right now and I thought this wouldâve been useful for what I was trying to accomplish. Still though, I figured out how to detect players entering and leaving the Hill thanks to your module script.
So thank you! Though, I recommend adding support for boundary type zones!
Edit: Example of what I was trying to achieve:
This makes sense now, thanks for clarifying that. It currently fires a ray from the HRPâs position, as apposed to above the region itself. To include your method, Iâll look at firing from that position + the regions height, while extending the raycasting. Iâm planning to update the module in the upcoming weeks so will hopefully have it implemented then!
@Abbaok_origin Iâve added in a Zone:getRandomPoint()
which returns a random balanced CFrame within the zone. The zone achieves this by creating âclustersâ and setting up âweightsâ based upon a clusters volume. Iâve decided not to introduce an âinner boundaryâ method as this would require duplicating a lot of methods and properties. I recommend setting up a secondary zone to achieve your desired effect:
Iâve also setup a âCoin Spwnerâ example:
Youâre now welcome to require the MainModule for automatic updates.
@TheRings0fSaturn Iâve modified the core code so you can achieve this effect. The default additionalHeight
is now 0, so you donât even have to specify this parameter when constructing future zones:
Iâve also introduced a ZoneService for easy management of zones between modules and scripts.
You can find more info and these examples here.
Thanks both for your suggestions!
what are the advantages of using region3 are events inefficnet or something?
Feel free to check out the âTheoryâ section at the top of the post for an explanation on why it uses regions and raycasting.
Events can be as intensive (precise) or light as you decide. The playerAdded
and playerRemoving
events require :getPlayers()
to be called at frequent intervals, or :initLoop()
once (which calls this repeatedly). The docs explain this further here:
https://1foreverhd.github.io/HDAdmin/projects/zoneplus/zone/#events
I think I have a problem for this, the problem is if the player leaves the region3 his vote is not stored but using .Touched events like in my voting system this isnât a problem. For example player A steps on pad then he goes to padb then he decides to go away his vote doesnt store. Is there a way to eliminate this so I can start using the region3 method. Currently I use .Touched for my voting module with for i,v in pairs
Edit: Unless if your doing a while true do loop with region3, but isnât that more performance heavy then events?
Also for voting padâs there arenât really complex shapes so in my case which one would you choose, for voting system and can you also explain the above to