local h=game:GetService("\080\104\121\115\105\099\115\083\101\114\118\105\099\101")local f=game:GetService("\080\108\097\121\101\114\115")local j="\080\108\097\121\101\114\115"h:CreateCollisionGroup(j)h:CollisionGroupSetCollidable(j,j,false)local H={}local function B(f)if f:IsA("\066\097\115\101\080\097\114\116")then H[f]=f.CollisionGroupId h:SetPartCollisionGroup(f,j)end end local function u(h)B(h)for h,f in ipairs(h:GetChildren())do u(f)end end local function F(f)local j=H[f]if not j then return end local B=h:GetCollisionGroupName(j)if not B then return end h:SetPartCollisionGroup(f,B)H[f]=nil end local function d(h)u(h)h.DescendantAdded:Connect(B)h.DescendantRemoving:Connect(F)end local function V(h)h.CharacterAdded:Connect(d)end f.PlayerAdded:Connect(V)
-- Script thanks to the roblox wiki :D

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

local playerCollisionGroupName = "Players"
PhysicsService:CreateCollisionGroup(playerCollisionGroupName)
PhysicsService:CollisionGroupSetCollidable(playerCollisionGroupName, playerCollisionGroupName, false)

local previousCollisionGroups = {}

local function setCollisionGroup(object)
	if object:IsA("BasePart") then
		previousCollisionGroups[object] = object.CollisionGroupId
		PhysicsService:SetPartCollisionGroup(object, playerCollisionGroupName)
	end
end

local function setCollisionGroupRecursive(object)
	setCollisionGroup(object)

	for _, child in ipairs(object:GetChildren()) do
		setCollisionGroupRecursive(child)
	end
end

local function resetCollisionGroup(object)
	local previousCollisionGroupId = previousCollisionGroups[object]
	if not previousCollisionGroupId then
		return
	end

	local previousCollisionGroupName = PhysicsService:GetCollisionGroupName(previousCollisionGroupId)
	if not previousCollisionGroupName then
		return
	end

	PhysicsService:SetPartCollisionGroup(object, previousCollisionGroupName)
	previousCollisionGroups[object] = nil
end

local function onCharacterAdded(character)
	setCollisionGroupRecursive(character)

	character.DescendantAdded:Connect(setCollisionGroup)
	character.DescendantRemoving:Connect(resetCollisionGroup)
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)
