Part doesn't detect being touched by another part of same name

So I want to make a pretty road generator, but sometimes the roads overlap. In order to prevent that I added a hitbox part to each road model with a script that detects if the hitbox detects another hitbox part. If the hitbox part detects another hitbox part, the road model gets destroyed.

hitbox

For some reason, the hitbox part doesn’t detect being touched by other hitbox parts and the script doesn’t work :frowning:

theystilloverlap

As you can see some roads still overlap and it looks bad. The hitboxes do detect if they touch decorations like those rocks on the right.

The hitboxes touch though…

Can anyone here explain why it doesn’t work?? I am lost!

Check if part’s property “CanTouch” is enabled

Perhaps using the WorldRoot:GetPartsInPart() function will yield better results.

.Touched events only fire an event if physics are involved, so it could be buggy when using teleports and anchored parts.

can touch is enabled
can collide is not enabled
transparency = 1

They are anchored? Maybe they are just falling off the map

they are indeed anchored and not falling through the map

hold up let me check how worldroot works

WorldRoot is the game instance. Raycasts also use the WorldRoot.


Example of this function:

local road = game.Workspace.Road

local partsInRoad = game:GetPartsInPart(road)

print(partsInRoad) --//This prints a table with all the parts in the instance
1 Like

game.Workspace:GetPartsInPart()


WorldRoot | Documentation - Roblox Creator Hub

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