Best way to check for any parts or terrain overlapping a region?

I’m trying to create an optimized anticheat that detects if users are flying. Sending a single raycast downwards is only so accurate because the player could be standing on the edge of something, and I want to avoid sending excess raycasts.

I was trying to incorporate searching for bounds that overlap with a given region, but functions like GetPartBoundsInBox() only return baseparts and not terrain. It’d be perfect if GetPartBoundsInRadius() also returned terrain.

The only solutions I can think of are to create a part and do GetTouchingParts() (but that would replicate the part to players which seems unnecessary and makes me mad) or I could send a few more raycasts, but I’m not sure what would be more optimized. Any suggestions would be great

Terrain inherits BasePart. Did it not work?

Raycasting is also very inexpensive so if sending more rays is easier, that could work as well.

GetPartBoundsInRadius(), GetPartsInPart() and GetPartBoundsInBox() do not detect Terrain, unless I’m missing an overlap param (I wasn’t using any overlap params)

Creating a part with a touch event connected and doing part:GetTouchingParts() does return terrain along with all overlapping parts

I will probably end up using GetTouchingParts() as the solution, but I’m disappointed that the others don’t acknowledge terrain since they seem like they’d be cleaner to use

3 Likes