GetPartsInPart Is Broken?

So I’m looping game.Workspace:GetPartsInPart(Part) to check if a part is inside or is touching the main base part.


However, the problem is that this works only if it’s in contact of parts either to the side or on top, but it doesn’t detect anything under itself.

Video demonstration:

‘Part’ is a basepart that detects the GetPartsInPart, this video demonstrates that regardless of collision or anchored, it neglects the bottom side of itself.

Any help would be great, thanks.

Note: I’m using more complex shapes later on, so using GetPartBoundsInBox wouldn’t be of help in those scenarios.

Maybe you could use Region3 to find the parts close to / in the part. Something like this maybe:

while task.wait() do
    local partPosition = script.Parent.Position
    local partSize = script.Parent.Size
    local region = Region3.new(partPosition - partSize/2, partPosition + partSize/2)
    local partsInRegion = workspace:FindPartsInRegion3(region, nil, math.huge)
    
    for _, part in pairs(partsInRegion) do
        -- Code
    end
end
1 Like

GetPartsInPart, as the name of the method suggests, will only get parts that are inside of the specified part. Naturally a part that is only touching it but not actually inside of it will not count so it’s working as intended.

You should attach a slightly larger invisible non-collide part to it and use that as the hitbox for your check instead to also get “touching” parts.

I understand what you’re saying and that method has also been attempted as well but still failed.


As shown in the video, the white block (detecting) is very well near the center of mass of the grey part but the output still prints out {}, aka nothing.

It was also demonstrated that the detecting part does not need something to be inside because it detects the touch of a wall when both parts are collidable and the detector is not anchored, aka physics does its thing and pushes them both outside of their volumes.

Try using BasePart:GetTouchingParts() if you want to detect parts that are both either touching (just on surfaces) or intersecting.
WorldRoot:GetPartsInPart() attempts to only query parts that are intersecting the part you are checking against. There is going to be some overlap against some surfaces due to float point errors.

A more comprehensive solution (for non regular shaped parts) might be raycasting or shapecasting from all faces using a very short ray to detect whether or not parts are touching.

Thanks for suggesting. I think the only problem with that is it wouldn’t be able to detect character limbs, but I’ll try out the raycasting method.

Edit: By “unable to detect limbs” I meant non collidable parts in general, including character limbs.

You should be able to detect any part using raycasts that has CanQuery enabled regardless of CanCollide or CanTouch status:

1 Like


I’ve tried using GetTouchingParts() with a non colliding wall and it only detects the block under itself but not the wall regardless of position or intersections. However I’m thinking about combining both techniques GetTouchingParts() and GetPartsInPart() to make it more accurate. Thanks.

1 Like

I think i found a solution although it’s pretty silly for Roblox to do.


According to the Roblox Creator Hub, a non collidable part must have a TouchInterest, which can only be done if I insert a function .Touched into the desired non collidable part.

This then makes it eligible to be detected by the separate GetTouchingParts(), detectable if it is either touching by surface or its volume inside the detecting part.

Proof:


Creates a table of the bottom part, and the wall (Non colliding physically).
Will give an update if it works perfectly.


Works very well, thank you everyone for helping.

Note: Either one of the interacting parts needs a TouchInterest, ex: Character limbs do not need TouchInterest if the Part already has one like in the video.

1 Like

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