Ragdoll Script sends character flying

Hello! So I have this ragdoll script, the issue is whenever its activated the character model spazzes out. Is there any way i can fix this?


Minor flash warning ^^

Heres the code

for _, v in pairs(clone:GetDescendants()) do
			if v:IsA("BasePart") then
				v:SetNetworkOwner(plr)
			end
			if v:IsA("Motor6D") then
				local Att0, Att1 = Instance.new("Attachment"), Instance.new("Attachment")
				Att0.CFrame = v.C0
				Att1.CFrame = v.C1
				Att0.Parent = v.Part0
				Att1.Parent = v.Part1
				local BSC = Instance.new("BallSocketConstraint")
				BSC.Attachment0 = Att0
				BSC.Attachment1 = Att1
				BSC.Parent = v.Part0
				if v.Part1.Name ==  "Head" then
					BSC.LimitsEnabled = true
					BSC.TwistLimitsEnabled = true
				end
				v.Enabled = false
			end
			if v.Name == "AccessoryWeld" then
				local WC = Instance.new("WeldConstraint")
				WC.Part0 = v.Part0
				WC.Part1 = v.Part1
				WC.Parent = v.Parent
				v.Enabled = false
			end
			if v.Name == "Head" and v:IsA("BasePart") then
				v.CanCollide = true
			end
		end

Help is greatly appreciated. Thank you for your time!

Two weeks old, but in case you still need help…

Setting the humanoid state on the client to “Physics” will make it not spaz out during ragdoll.

local Plr = game.Players.LocalPlayer
local Char = Plr.Character

Char:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.Physics)

And then setting it to “GettingUp” if you disable ragdoll.

Char:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.GettingUp)