Problem with CanCollide

Hello, I am having an issue with CanCollide. It is not working properly in my game. I want the “Stand” to be able to pass through other Players and external objects like parts. However, It doesn’t seem to do that.

Here is the code below. I used a fixed loop to iterate through the Stand’s parts and check if they are a part and then I the CanCollide on them to false:

-- SETTING THE STAND TO NOT BE ABLE TO COLLIDE WITH EXTERNAL PARTS
	for _, part in pairs(Stand:GetDescendants()) do
		if part:IsA("Part") then
			part.Massless = true
			part.CanCollide = false
		end
	end

It doesn’t seem to work. Maybe I did it wrong, or maybe there is another way of doing this?
Any help is appreciated.

1 Like

Do you want to check for every type of part or just normal parts?

Every part, I think as I want the stand to pass through objects don’t want any parts to not get passed through.

Then you should do this:

for _, part in pairs(Stand:GetDescendants()) do
	if part:IsA("BasePart") then
		part.Massless = true
		part.CanCollide = false
	end
end

You might be interested in PhysicsService
And CollisionGroups

Ahh, true. Forgot about collision groups.

Other Solutions could be:

  1. Make sure the script is server sided
  2. Disable collisions manually, before even running the game (In the Explorer)

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