GetTouchingParts Bug/Inquiry

I’ve been fiddling with trying to do a hitbox that performs box:GetTouchingParts()

It’s been working great in my other games, but in this new game, it does not detect certain parts that are within a model that have CanCollide true, Anchored false, and Archivable true. I’ve made the hitbox very big and the part itself big as well (both greater than 5 studs in each axis).

The hitbox always detects the character model body parts, but fails to detect a custom model that is built at runtime. As soon as I put the parts in the workspace, or just clone the parts and put them in the workspace instead of directly in the model, they can be detected by the hitbox. It’s a very peculiar problem and I’d like to know if there are any problems with parts built at runtime and collisions?

Any help will be awesome :smiley:

1 Like

Have you tried using region3? if not then make it the size as the hitbox and then get the parts inside the region3.

1 Like

Region3 is even less accurate than GetTouchingParts, by construct

1 Like

How is Region3 less accurate?


Again, the issue here is GetTouchingParts(). It is not detecting supposedly valid parts in a model, and i want to know if there are patterns to look for

1 Like

Can you extract a minimal model that has this issue and attach it? Someone might be able to find the issue that way.


Good idea, I’ll post this shortly.

EDIT: here is a simple .rbxl file that shows the problem: car-test-hitboxes.rbxl (152.5 KB)

If you go to my serverscriptservice and find the User module, and go to the #addPart method, you will find TEST1. I set it to false to show the error, which is where it tries to weld to nearby parts in the model, and it fails by only detecting the chassis and seat, not any of the parts built on it.

In the game, whenever you build, you will see a red hitbox that checks for nearby parts, and the output console will print all the touching parts of that box. Currently it detects none of the custom parts that are in the car model.

Here is an even more streamlined .rbxl that shows the issue. Same instructions as before: car-test-hitboxes.rbxl (25.6 KB)

yes that looks great! how did you achieve this?

Although this does fix the problem in the test place, I replicated the code to my actual game and it does not detect the parts again.

Your solution is also confusing to me, because all you did was move the part to the place it is supposed to be welded to, although that should not matter in terms of checking for other colliding parts.

The check in the box that the part is not being welded to itself also is not related to the GetTouchingParts method, so I’m still confused.

I’m going to dig around more to see what I changed in my game to make the test place.

I think it might actually be a bug with how GetTouchingParts works with welds. Because all the parts don’t have a predefined CFrame and are only assigned a CFrame indirectly via weld.C1, it might be ignored by the collision method. One odd solution is to do this check on the client only, which surprisingly works.

I even tried this with region3, and I’m getting the same functionality as .Touched

Fiddled around with it more, now its just working on some tests and others it doesn’t, even if I change nothing between them. I am almost completely sure its some engine quirk that is stopping the GetTouchingParts() detection from occuring.

It seems to more specific to also detection on ANCHORED welded parts, where normal anchored parts are always correctly detected by GetTouchingParts().

I made another small test just with one CanCollide true anchored part and an unanchored CanCollide true part welded to the anchored part. I tried doing GetTouchingParts() on the welded unanchored part, but it was not detecting. I think this is the pinpointed bug at its finest.

I can’t post on the studio/engine bug reports, but I believe this is something that needs to be fixed for collisions.

Thanks for the report. There’s definitely a bug here but it’s not related to the change to how unanchored objects welded to anchored objects behave. That change only slightly changed the way this bug manifests.

It appears if you move an unanchored part at all after welding it to an anchored part (either by the weld moving it or setting the CFrame property on the unanchored part directly) our broadphase doesn’t appear to update the position of that part correctly. Because of this FindPartsInRegion3 or GetTouchingParts won’t correctly find the part there. I’ll file a ticket and we’ll look into this later.

For now you can work around this by setting the position of the part to it’s destination before creating the weld. If you do this it appears to work correctly. I added part.CFrame = frame after part.Parent = self.carModel in the script you mention and it worked.

1 Like

Yes it works sometimes, but at other times it still does not weld correctly, or simply immediately destroys the weld. Again, the test place here works but when I transition to my actual game and use the exact same script, it either fails outright or fails most of the time. I can probably give you the link to the game or teamcreate with you to show you what I mean.

Thanks again for the response, hopefully this is fixed soon.

Found out why it does not work sometimes, its because I load in a build with saved welds, therefore I didn’t consider the part.CFrame hack that I must apply to all loaded in parts. So my particular problem is solved!