R15 Ragdolling with Collision Filters

I’m trying to create a ragdoll for my r15 game, but I’m struggling to use collision filters so that the body doesn’t clip whilst in platform stand, but it doesn’t work and I’m not sure what to do

local Ragdoller = {}


function Ragdoller.Ragdoll(Character)
	local PhysicsService = game:GetService("PhysicsService")
	if Character:FindFirstChild("Ragdoll") then return 
	end
	Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
	Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
	Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
	Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
	Character.HumanoidRootPart.CanCollide = false
	Character.Humanoid.WalkSpeed = 0
	Character.Humanoid.PlatformStand = true
	Character.Humanoid.AutoRotate = false
	Character.Humanoid.JumpPower = 0
	local PlayerGroup = PhysicsService:CreateCollisionGroup("p")
	PhysicsService:CollisionGroupSetCollidable("p","p",true)

	for i, joint in pairs(Character:GetDescendants()) do
		if joint:IsA("Motor6D") and joint.Name ~= "Neck" and joint.Name ~= "Root" and joint.Name ~= "LeftWrist" and joint.Name ~= "RightWrist" then
			local socket = Instance.new("BallSocketConstraint")
			local a1 = Instance.new("Attachment")
			local a2 = Instance.new("Attachment")
			a1.Parent = joint.Part0
			a2.Parent = joint.Part1
			socket.Parent = Character.UpperTorso
			socket.Attachment0 = a1
			socket.Attachment1 = a2
			socket.Name = joint.Name.."'s".."Socket"
			a1.CFrame = joint.C0
			a2.CFrame = joint.C1
			socket.TwistLimitsEnabled = true
			socket.LimitsEnabled = true
			joint.Enabled = false
			
			for i,v in pairs(Character:GetDescendants()) do
				if v:IsA("MeshPart") or v:IsA("BasePart") then
					PhysicsService:SetPartCollisionGroup(v,"p")
				end
			end

		end
	end
end

return Ragdoller