Make part not collide with player

Hi! So I was wondering if it’s possible to make a script that I could put into a part, that would make it non collidable with players, but collidable with other parts. If so, how would I do this?

9 Likes

Take a look at this and change it to the part you want. I’d use tags for parts that will have this functionality.

3 Likes

Yes there is. You can make it so that it can/can’t collide with objects and just check if the object is a humanoid and if so turn can collide On or Off.

if objectname.Touched = true and objectname.Touched:Connect(Humanoid) if Humanoid = true then objectname.Cancollide = True(or False) Or objectname.Cancollide.Disabled = false (or true)

Dont forget to define humanoid. Local humanoid =

2 Likes

So what would the script be if my part was name “Part”?

You should put a LocalScript somewhere in StarterGui with this code:

local part = game:GetService("Workspace"):WaitForChild("Part")
part.CanCollide = false

The part won’t collide on Local Player but it will collide on the server (with other parts).

The following code results in setting CanCollide property of a part to false on client when you can see that it is still true on server. The behaviour of the parts can be seen here:

Here’s a testing Baseplate for this: Baseplate.rbxl (22.8 KB)

9 Likes

Replace objectname with part, ( but that was only an example, I don’t think I will work) You have to customize it for your game.

Highly suggest looking into collision groups, if you want to make it where the part will only go through players :slight_smile:

5 Likes

It seems to not work, I changed the name of the part and everything. They’re in ReplicatedStorage inside a model so I have changed WorkSpace to ReplicatedStorage

1 Like

It has to be in the Workspace I believe. My example works perfectly fine.

If you are cloning the thing from Server to Workspace you can listen to ChildAdded event in LocalScript. If child’s name would be something that you want to set CanCollide property to false then make it child.CanCollide = false, like this (it should be a LocalScript somewhere in StarterGui or StarterPack etc.):

game:GetService("Workspace").ChildAdded:Connect(function(child)
    if child.Name == "PartNameHere" then
        child.CanCollide = false
    end
end)
1 Like

I edited it, and it still is not working. The part is inside a model called “Logs”, the part is called “op” and it’s inside replicated storage.

1 Like

It would work if it gets cloned from Replicated to Workspace.

The model gets cloned form replicatedstorage to workspace (With the parts in it)

So you need to use this instead:

game:GetService("Workspace").ChildAdded:Connect(function(child)
   for i, v in pairs(child:GetDescendants()) do
      if v.Name == "PartNameHere" and v:IsA("Part") then
           v.CanCollide = false
      end
   end
end)

Would I make it

	for i, v in pairs(child:GetDescendants()) do
		if v.Name == "op" and v:IsA("Part") then
			v.CanCollide = false
		end
	end
end)```

Just change the name in brackets to your part’s name and it should work.

so the part falls through the ground, I think the whole part is non collide.

Yeah, when I change it to “true” it doesn’t fall through the ground, but it also is collidable with players.

1 Like

You should change it to false???

No, I did. But it falls through the ground.

Most of these answers are incorrect.
You should not make a script that changes collisions in a Touched event, nor should you change the player’s collisions. You should use Collision Groups for this.

4 Likes