Disable Player's Collision

So due to update in CollisionGroups (Updates to Collision Groups), old methods of disabling player-player collision don’t work.
I tried using this script:

local PS = game:GetService("PhysicsService")
local Players = game:GetService("Players")

PS:RegisterCollisionGroup("Player")
PS:CollisionGroupSetCollidable("Player", "Player", false)

local function assignPlayerCollisionGroup(char:Model?)
	char:WaitForChild("HumanoidRootPart")
	char:WaitForChild("Head")
	char:WaitForChild("Humanoid")

	for i, v:Instance in pairs(char:GetDescendants()) do
		if v:IsA("BasePart") then
			v.CollisionGroup = "Player"
		end
	end
end

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		assignPlayerCollisionGroup(char)
	end)
end)

for i, plr:Player in ipairs(Players:GetChildren()) do
	repeat wait() until plr.Character
	assignPlayerCollisionGroup(plr.Character)
end

But it doesn’t work (console is clear, player’s collisions are not disabled).

What method is working?

Do you want no collision with other players or with the workspace

1 Like

The problem may be because some character assets are not fully loaded yet, so I would recommend using the CharacterAppearanceLoaded event instead of CharacterAdded

9 Likes

I want no collision for players.

If anyone is interested, here is the code:

local PS = game:GetService("PhysicsService")
local Players = game:GetService("Players")

PS:RegisterCollisionGroup("Player")
PS:CollisionGroupSetCollidable("Player", "Player", false)

local function assignPlayerCollisionGroup(char:Model?)
	char:WaitForChild("HumanoidRootPart")
	char:WaitForChild("Head")
	char:WaitForChild("Humanoid")

	for i, v:Instance in pairs(char:GetDescendants()) do
		if v:IsA("BasePart") then
			v.CollisionGroup = "Player"
		end
	end
end

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(function(char)
		assignPlayerCollisionGroup(char)
	end)
end)

removed last part of code because it was useless

6 Likes

it didnt work for me I don’t know why

Probably because the script loads after the player.
You can use for loop to assign player collision.

-- at the end of the code
for i, plr in ipairs(Players:GetChildren()) do
 local char = plr.Character
 assignPlayerCollisionGroup(char)
end
1 Like

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