Players Head Keeps Clipping Through Ground Leading To Glitching

I am trying to make a ragdoll system, everything is perfect, the only problem is that a recent update broke my script and now the head won’t collide with the ground, leading to the head glitching out and shaking around!

I have tried messing with more state types, but nothing works.
I would like any suggestions that could help fix this problem. Thank you!

Problem:

Script Exerpt, (please tell me if you need any more parts, I have a module, along with a local script.

	character.Humanoid.PlatformStand = true
	character.Humanoid.BreakJointsOnDeath = false
	character.Humanoid.AutoRotate = false
	character.Humanoid.RequiresNeck = false

	character.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
---	character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics,true)
	
	local Motor6dsTable = {}
	local SocketTable = {}
	local Attaches = {}
	
	for i, v in pairs(character:GetDescendants()) do
		if v:IsA("Motor6D") then

			local attach0 = Instance.new("Attachment")
			attach0.Name = v.Part0.Name.."Attach"
			local attach1 = Instance.new("Attachment")
			attach1.Name = v.Part1.Name.."Attach"

			attach0.CFrame = v.C0
			attach1.CFrame = v.C1
			attach0.Parent = v.Part0
			attach1.Parent = v.Part1
			
			table.insert(Attaches,attach0)
			table.insert(Attaches,attach1)
			
			local ballSocketConstraint = Instance.new("BallSocketConstraint")
			ballSocketConstraint.Name = "BallSocketConstraint"
			ballSocketConstraint.Attachment0 = attach0
			ballSocketConstraint.Attachment1 = attach1
			ballSocketConstraint.Parent = v.Parent
			ballSocketConstraint.TwistLimitsEnabled = true
			ballSocketConstraint.LimitsEnabled = true
			ballSocketConstraint.Parent = v.Parent
			table.insert(SocketTable,ballSocketConstraint)
			
			if keepJoints == nil or keepJoints == false then
				v:Destroy()
			elseif keepJoints == true then
				v.Enabled = false
				--v.Parent = nil
				table.insert(Motor6dsTable,v)
			end
		end
	end
	
	character.Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
	character.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	character.Humanoid.PlatformStand = false
---	character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.PlatformStanding,false)
---	character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics,true)
--	character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,true)


	local playerTry = game.Players:GetPlayerFromCharacter(character)
	if playerTry then 
		character.PrimaryPart.CanCollide = false
		character.PrimaryPart:SetNetworkOwner(playerTry)
		game.ReplicatedStorage:WaitForChild("SendRagdollChangesToClient"):FireClient(playerTry,"Full",character.Humanoid)
	else
		character.PrimaryPart.CanCollide = false
		character.PrimaryPart:SetNetworkOwner(nil) 
	end

I’d suggest reverting the update to a version where the script worked & going from there.

Only problem is that this is a module looking to be able to used in several games of mine. And so I can’t really afford to revert updates.