Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

CanCollide not working on my character?

Hello! I made a script to make me go through parts in the workspace, to do so I used a RemoteEvent that makes each part of my character CanCollide = false and it actually works, but it still won't let me go through parts. Here is my script. :) Any help?

local db = false
local Character = script.Parent.Parent.Parent


game.ReplicatedStorage.RemoteEvents.PermeationSkill.Permeate.OnServerEvent:Connect(function(plr)
    plr.Character.Humanoid.MaxHealth = 15
    plr.Character.Humanoid.Health = 15

    for i,v in pairs(Character:GetDescendants()) do
        if v:IsA("BasePart") then
            v.CanCollide = false
            v.Transparency = 0.65
            Character.Humanoid.WalkSpeed = 7
        end
    end
end)

4 comments

0

try setting Platfrom stand to true in the humanoid..?

0

wait-

0

do you want to go through objects?

0

Yes.

3 answers

local PS = game:GetService("PhysicsService")
PS:CreateCollisionGroup("Player")
PS:CollisionGroupSetCollidable("Player","Player",false)

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Character:WaitForChild("HumanoidRootPart")
		Character:WaitForChild("Head")
		Character:WaitForChild("Humanoid")
		for i,v in pairs(Character:GetChildren()) do
			if v:IsA("BasePart") then
				PS:SetPartCollisionGroup(v,"Player")
			end
		end
	end)
end)

1 comment

0

Doesn't work.

The HumanoidRootPart Is Can Go Through, But The Other Parts Cant.

You Need To Change The Cancollide For Every Part.

If You Want It To Do It By Script,

for _, child in pairs(script.Parent:GetChildren()) do
		if child:IsA("Part") then
			child.Cancollide = false
		end
		
		-- You Can Also Put An Elseif instead.
		if child:IsA("BasePart") then
			child.Cancollide = false
		end
	end

Or Manually,

Select Each Body Parts And Change The Cancollide.

5 comments

0

How do I do that?

0

One Sec.

0

Edited.

0

Still won't work.

0

Actually, Try Use Collision Group ID, Try 3 I Think.

I just fixed this by using a Touched event and make the parts I touch CanCollide = false.

This discussion is preserved as it was. New answers, comments, and votes are closed.