Ragdolls Breaking (Having seizures for no reason)

Hello all, so I am working on a game that ragdolls a players character when they die. The server detects if they died or if they no-longer have humanoid and will make them ragdoll through this script. It worked great until both roblox and studio had an update. Now its broken. I have tried looking up solutions but nothing with the similar issue popped up. I tried borrowing code from other ragdoll free-model scripts but that didn’t help. The ragdolls have a seizure and freak out and then get deleted. A solution would be greatly appreciated. (Please don’t suggest free models/scripts to me, I want to fix what I have instead. It’ll be much easier on me.)

local Character = script.Parent
local NewHumanoid = Character:FindFirstChild("Humanoid") 
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)

--------------------------------------------------------------------
function MakeCollidingPart(BodyPart)
	local CollisionPart = Instance.new("Part")
	CollisionPart.Size = Vector3.new(1,1,1)
	CollisionPart.Transparency = 1
	CollisionPart.CFrame = BodyPart.CFrame * CFrame.new(0, -0.5, 0)
	CollisionPart.Parent = BodyPart.Parent
	local W = Instance.new("Weld")
	W.Part0 = BodyPart
	W.Part1 = CollisionPart
	W.C0 = CFrame.new(0, -0.5, 0)
	W.Parent = BodyPart
end


if Character.Archivable ~= true then
	Character.Archivable = true
end
local NewCharacter = Character:Clone()
if NewHumanoid == nil then
	NewHumanoid = Instance.new("Humanoid",NewCharacter)
end

local Head = NewCharacter:FindFirstChild("Head")
local RightArm = NewCharacter:FindFirstChild("Right Arm")
local RightLeg = NewCharacter:FindFirstChild("Right Leg")
local LeftArm = NewCharacter:FindFirstChild("Left Arm")
local LeftLeg = NewCharacter:FindFirstChild("Left Leg")
local Torso = NewCharacter:FindFirstChild("Torso")

for _,Descendant in pairs(NewCharacter:GetDescendants()) do
	if Descendant:IsA "Motor6D" then
		Descendant:Destroy()
	elseif Descendant:IsA "Weld" and not Descendant.Parent.Parent:IsA "Accessory" and not Descendant.Parent.Parent:IsA "Hat" then
		Descendant:Destroy()
	elseif Descendant:IsA "Attatchment" and not Descendant.Parent.Parent:IsA "Accessory" and not Descendant.Parent.Parent:IsA "Hat" then
		Descendant:Destroy()
	end
	if Descendant:IsA "BasePart" and Descendant.CanCollide ~= true and not Descendant.Parent:IsA "Accessory" and not Descendant.Parent:IsA "Hat" then
		Descendant.CanCollide = true
	end
end

local NewTorsoToHead1 = Instance.new("Attachment")
NewTorsoToHead1.Position = Vector3.new(0, -0.6, 0)
NewTorsoToHead1.Name = "Neck"
NewTorsoToHead1.Parent = Head

local NewTorsoToRightArm1 = Instance.new("Attachment")
NewTorsoToRightArm1.Position = Vector3.new(-0.5, 0.5, 0)
NewTorsoToRightArm1.Name = "Right Shoulder"
NewTorsoToRightArm1.Parent = RightArm

local NewTorsoToRightLeg1 = Instance.new("Attachment")
NewTorsoToRightLeg1.Position = Vector3.new(0, 1, 0)
NewTorsoToRightLeg1.Name = "Right Hip"
NewTorsoToRightLeg1.Parent = RightLeg

local NewTorsoToLeftArm1 = Instance.new("Attachment")
NewTorsoToLeftArm1.Position = Vector3.new(0.5, 0.5, 0)
NewTorsoToLeftArm1.Name = "Left Shoulder"
NewTorsoToLeftArm1.Parent = LeftArm

local NewTorsoToLeftLeg1 = Instance.new("Attachment")
NewTorsoToLeftLeg1.Position = Vector3.new(0, 1, 0)
NewTorsoToLeftLeg1.Name = "Left Hip"
NewTorsoToLeftLeg1.Parent = LeftLeg
-------------------------------------------------------
local NewTorsoToHead0 = Instance.new("Attachment")
NewTorsoToHead0.Position = Vector3.new(0, 1, 0)
NewTorsoToHead0.Name = "Neck"
NewTorsoToHead0.Parent = Torso

local NewTorsoToRightArm0 = Instance.new("Attachment")
NewTorsoToRightArm0.Position = Vector3.new(1, 0.5, 0)
NewTorsoToRightArm0.Name = "Right Shoulder"
NewTorsoToRightArm0.Parent = Torso

local NewTorsoToRightLeg0 = Instance.new("Attachment")
NewTorsoToRightLeg0.Position = Vector3.new(0.5, -1, 0)
NewTorsoToRightLeg0.Name = "Right Hip"
NewTorsoToRightLeg0.Parent = Torso

local NewTorsoToLeftArm0 = Instance.new("Attachment")
NewTorsoToLeftArm0.Position = Vector3.new(-1, 0.5, 0)
NewTorsoToLeftArm0.Name = "Left Shoulder"
NewTorsoToLeftArm0.Parent = Torso

local NewTorsoToLeftLeg0 = Instance.new("Attachment")
NewTorsoToLeftLeg0.Position = Vector3.new(-0.5, -1, 0)
NewTorsoToLeftLeg0.Name = "Left Hip"
NewTorsoToLeftLeg0.Parent = Torso

local function CreateBallSocket(Attachment0, Attachment1, TwistLowerAngle, TwistUpperAngle)
	local BallSocket = Instance.new("BallSocketConstraint")
	BallSocket.Parent = Torso
	BallSocket.Attachment0 = Attachment0
	BallSocket.Attachment1 = Attachment1
	BallSocket.LimitsEnabled = true
	BallSocket.TwistLimitsEnabled = true
	BallSocket.TwistLowerAngle = TwistLowerAngle
	BallSocket.TwistUpperAngle = TwistUpperAngle
	BallSocket.MaxFrictionTorque = 10
end
CreateBallSocket(NewTorsoToHead0, NewTorsoToHead1, -45, 45)
CreateBallSocket(NewTorsoToRightArm0, NewTorsoToRightArm1, 45, 0)
CreateBallSocket(NewTorsoToLeftArm0, NewTorsoToLeftArm1, 0, 45)
CreateBallSocket(NewTorsoToRightLeg0, NewTorsoToRightLeg1, -45, 45)
CreateBallSocket(NewTorsoToLeftLeg0, NewTorsoToLeftLeg1, -45, 45)
MakeCollidingPart(RightArm)
MakeCollidingPart(RightLeg)
MakeCollidingPart(LeftArm)
MakeCollidingPart(LeftLeg)


if NewCharacter.PrimaryPart then
	NewCharacter.PrimaryPart:Destroy()
end
NewCharacter.Name = "Ragdoll"
NewHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
NewCharacter.Parent = game:GetService("Workspace")
wait()
Character:Destroy()
wait(14)
NewCharacter:Destroy()

Oh also one of the threads I read said to use NoCollisionConstraints for a similar issue but it didn’t help.