How to make a part not collide with players but with other parts

I have made a localscript that toggles the cancollide property but it only works once

3 Likes

I think you should start experimenting with collision groups.

The article I linked does a really good job at explaining how it works.

1 Like

can you give me a code example to get me started?

The article has plenty code examples?

This question seems to have been already asked, so maybe you can go check through the answers and find one that’ll work for you

Where can i get the collision group editor?

local character = game.Players.LocalPlayer.Character
local physics = game:GetService('PhysicsService')
physics:CreateCollisionGroup("Object")
physics:SetPartCollisionGroup(your part here, "Object")
physics:SetPartCollisionGroup(character, "Object")
physics:CollisionGroupSetCollidable("Object", "Object", false)

(Didn’t test this yet.)

1 Like

In studio, go to the MODEL tab, and on the far right you will see the Collision Group button, click that to open up the editor

when the object gets destroyed is it auto removed from the collision group?

i want to make it so the player can go through the obstacle but the other parts cannot

Yes, also why would it matter if it still was in the collision group?

Try this code:

local character = game.Players.LocalPlayer.Character
local physics = game:GetService('PhysicsService')
physics:CreateCollisionGroup("Object")
physics:SetPartCollisionGroup(your part here, "Object")
physics:SetPartCollisionGroup(character, "Object")
physics:CollisionGroupSetCollidable("Object", "Object", false)

because my code clones the parts every 5 sec so idk there to be error

Wrote this code but when i try to pass the ball blocker i still cannot

Edit: I fixed it