How to make Body part not touch a specific part (object)

Does anyone know how to make a body part not touch a specific part (object) ?

I’m trying to make the Right Leg of a body part not be able to touch a specific part but it can touch other parts

like this -

Have a look at CollisionGroups and Collision Filtering! Seems to be what you want

1 Like

So i basically create custom collision filtering?, Im confused on where i do it.

Alright.

In studio, under the model tab, click Collision Groups
image

Then, create a new collision group (or 2. You may need 2 for your use case)
Set it so that these 2 groups do not collide
Set the collision group of one of the parts to 1 group, and the collision group of the other to the other group

I did it and unchecked it and it doesnt work
image

Using code, hvae you set the collision group of the RightLeg? Also the collision group of the part that it shouldn’t touch

Do i put the script in serverscriptservice?

I changed the collision group names too “RightLeg” and “Part”

heres the script if you wanted to see

local PhysicsService = game:GetService(“PhysicsService”)

local RightLeg = “RightLeg”
local Part = “Part”

PhysicsService:RegisterCollisionGroup(RightLeg)
PhysicsService:RegisterCollisionGroup(Part)

workspace.RightLeg1.CollisionGroup = RightLeg
workspace.Part1.CollisionGroup = Part

PhysicsService:CollisionGroupSetCollidable(RightLeg, RightLeg, false)
PhysicsService:CollisionGroupSetCollidable(RightLeg, Part, false)

PhysicsService:RegisterCollisionGroup(RightLeg)
PhysicsService:RegisterCollisionGroup(Part)

PhysicsService:CollisionGroupSetCollidable(RightLeg, RightLeg, false)
PhysicsService:CollisionGroupSetCollidable(RightLeg, Part, false)

As you created these in the Collision Group Editor, you don’t need to recreate them. Doing so could cause issues

I removed both of the issues, its still not working.

Should this be the rightleg of the PLAYER or…?

it also shows errors in the script

Yes the rightleg of the player

The quotation marks you’re using are bad, replace them with this "

2 Likes

this is probably the easiest way