Why does my ragdolled NPC start flinging around in circles?

Basically, I’m working on an npc that ragdolls when it dies, While making the ragdoll script, I came across this weird bug! Help would be appreciate :smiley:

Script:

for i,v in pairs(script.Parent:GetDescendants()) do
	if v:IsA("Motor6D") and v.Parent.Name ~= "HumanoidRootPart" then
		local Socket = Instance.new("BallSocketConstraint")
		local a1 = Instance.new("Attachment")
		local a2 = Instance.new("Attachment")
		a1.Parent = v.Part0
		a2.Parent = v.Part1
		Socket.Parent = v.Parent
		Socket.Attachment0 = a1
		Socket.Attachment1 = a2
		a1.CFrame = v.C0
		a2.CFrame = v.C1
		Socket.LimitsEnabled = true
		Socket.TwistLimitsEnabled = true
		v:Destroy()
		script.Parent.Humanoid.HipHeight = 0
	end
end
script.Parent.Character.Humanoid.RequiresNeck = false
script.Parent.Character.Humanoid.Sit = true

Try to set the .CanCollide property of the limbs to true


I did that but it just kept flinging and eventually returned to its original error.

Can you try setting the HipHeight to 1 and see if that helps.

That intensified the shaking and then after a while it went back to face and feet in ground