How would I detect client sided touch detection

The title speaks for itself. I am making a building system and I don’t want parts intersecting with other parts. Currently, I am using raycasting and I am making a hitbox for each part in the workspace. The only problem is that the hitbox making is really non-efficient. How would I check if a part is intersecting with another part and not use raycasting and hitboxes?

Thanks,
Dragon

You could use GetTouchingParts() which return back an array of Touching Parts that the current TargetPart is touching?

It doesn’t work on the client side.

You can use region3 to quickly create a region and check if there’s any other parts inside your part’s hitbox range.

Read about region 3 here

Alternatively, you can use this bit of code to create a region3 within a part:

local part= -- the part you want the region to scan for parts inside of.
local min,max = Vector3.new(part.Position.X-part.Size.X/2, part.Position.Y-part.Size.Y/2, part.Position.Z-part.Size.Z/2), Vector3.new(part.Position.X+part.Size.X/2, part.Position.Y+part.Size.Y/2, part.Position.Z+part.Size.Z/2)
local region = Region3.new(min, max)

After that you can scan for parts inside using this

local parts = workspace:FindPartsInRegion3(region) --Returns an array of parts inside the region
1 Like

Thank you so much!! Helps a lot!

1 Like