ZonePlus how to get specific touching part within a Zone

So Im using ZonePlus, and am wondering if its possible to get a specific part within a zone that I am touching (my player) - Look at the picture I drew for a better understanding.

Does ZonePlus have a function or similar for referencing this specific part within a zone that the player is touching?

To be completely frank, I just skimmed over ZonePlus’ documentation; But from what I understand, I have two solutions to your problem

Assuming you have a zone set with zone.new, you can find out in which zone a player is in, by:

  • Checking if a zone has your player with zone:getPlayers()
  • Cache every players’ respective zone with the playerEntered and playerExited functions

If you want to be optimized, you’ll really want to use the latter.

Hope this helps!

Bro as much as I appreciate your response, I am trying to figure out how to get a specific zone part from within a Zone created of mutliple parts. to see which one you touched - not trying to get the whole zone.

Ohh, I get it now. In that case you may want to use an individual zone for each part (on top of a generalized one for multiple parts, for whatever purpose you have it).

If you want a more optimized (yet more inconvenient) approach, you can always try modifying the module to account for this behavior.

Actually, I’ll try that. I’ll edit this message if I do it.

I tried modifying the module to make the second argument the touching piece within a zone but lowkey I dont know how to do that

I DID IT!!!

kinda happy cause its the first time ive successfully edited a module but meh

I think that instead of explaining you what to change, I’ll just give you the modified module and some sample code. It should work as zone:getPlayer(player_name: string) and it should return the Part from zone where player is in.

Although, do seriously note that the changes are not optimized. The module originally iterates through all players with great optimization to check for their respective zones, but now for every iteration it checks whether or not its checking over the specifically given player (string), using the function or not. It also adds even more checks to ensure it returns the part and not cause errors.

And to be clear, I still recommend using multiple zones for performance purposes. Here’s the file though.
silly.rbxm (36.5 KB)

Feel free to ask any questions and if you feel your topic has been answered, make sure to mark a solution :smiley:

well done, I salute you. Will surely be useful for others and hope Zoneplus makes an update to allow the playerentered function to have a second parameter that lets users know what parts the user is touching within that zone. Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.