Somehow I cannot remove player collision

Basically, I tried to make a script to remove player collision and uh, I dunno how I screwed this up.
Script:

local player = game.Players.LocalPlayer

game.Players.PlayerAdded:Connect(function(player)
	if player:WaitForChild("Character") then
		player.Character.Torso.CanCollide = false
		player.Character.HumanoidRootPart.CanCollide = false
		player.Character.Head.CanCollide = false
	end
end)
2 Likes

So what is the issue?
If you make all your Parts CanCollide false then you’ll drop through the ‘floor’.

The issue is that I can still collide with other players.

Use CollisionGroups.

1 Like

Put this script in serverscriptservice:

local PhysService = game:GetService('PhysicsService')
local PlayerGroup = PhysService:CreateCollisionGroup('Player')
PhysService:CollisionGroupSetCollidable('Player','Player',false)

function NoCollide(Player)
   for k,v in pairs (Player:GetChildren()) do
        if v:IsA('BasePart') then
            PhysService:SetPartCollisionGroup(v,'Player')
        end
    end
end

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        NoCollide(Character)
    end)

    if Player.Character then NoCollide(Player.Character) end
end)
4 Likes

But what is this part for?

function NoCollide(Player)
   for k,v in pairs (Player:GetChildren()) do
        if v:IsA('BasePart') then
            PhysService:SetPartCollisionGroup(v,'Player')
        end
    end
end

The script is wrong.

The right script:
local PhysicsService = game:GetService(‘PhysicsService’)

PhysicsService:CreateCollisionGroup(‘Players’)
PhysicsService:CollisionGroupSetCollidable(‘Players’, ‘Players’, false)

local function disableCollision(obj)
if obj:IsA(‘BasePart’) then
PhysicsService:SetPartCollisionGroup(obj, ‘Players’)
end
end

local function setup(model)
for i, obj in pairs(model:GetDescendants()) do
disableCollision(obj)
end
model.DescendantAdded:connect(function(obj)
disableCollision(obj)
end)
end

game:GetService(‘Players’).PlayerAdded:connect(function(player)
if player.Character then
setup(player.Character)
end
player.CharacterAdded:connect(function(char)
setup(char)
end)
end)

1 Like

There are even better scripts for it.

This is to set the player’s parts to the collisiongroup

Oh!

30 Chars

Im still confused, what is the solution now.

Search Video Tutorials, there are TONS. And they are pretty good.

The script I posted works as intended

Certain parts of the character are forced to have CanCollide set to true, no matter how much you try to set it otherwise. Like others said, the best way to disable player collision is to use collision groups.

1 Like

This one works I couldn’t find anything else on the forum that does for R15.