What would be the most optimized way to detect if a player is inside a part?

Hello, what would be the most optimized and least task intensive way of detecting if a player gets inside of an invisible hitbox (a part) and if they get out of the hitbox? I’ve seen solutions that uses GetTouchingParts loops but I feel like it would be task intensive if a server script is constantly checking for the HumanoidRootPart inside the hitbox, and even more if there are multiple hitboxes that needs to be checked. Any help would be greatly appreciated!

2 Likes

Math. Get the coordinate of the area, the position of the player, and check the numbers themselves.

1 Like

This is the part where you consider using things other people made (ZonePlus)

1 Like

Turns out skidding was the way to success. Thank you.
ezgif.com-video-to-gif_2

I feel like zoneplus is overkill for most simple use cases, when what that library does at the lowest level is essentially just :GetPartsInBox() binded to RunService.Hearbeat with a lot of bloat stacked ontop.

It was a complete dealbreaker for me since it does not support custom collision groups for the hitboxes/zones parts

zoneplus’ solution to the multiple hitbox problem if I recall correctly is just to store a table with all the zones, that it goes through within a single connection to the .Hearbeat event

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