Why does my ragdoll fly up

I have this ragdoll script I made and when you go into ragdoll mode then your entire body just floats up when ragdolled but when reversed then your character acts normally help

game.Players.PlayerAdded:Connect(function(plr)
	local character = game.Workspace:WaitForChild(plr.Name)
	local d = character:GetDescendants()
	for i=1,#d do
		local desc = d[i]
		if desc:IsA("Motor6D") then
			local socket = Instance.new("BallSocketConstraint")
			local part0 = desc.Part0
			local joint_name = desc.Name
			local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment")
			local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment")
			if attachment0 and attachment1 then
				socket.Attachment0, socket.Attachment1 = attachment0, attachment1
				socket.Parent = desc.Parent
				desc.Enabled = false
			end	
		end
	end
end)

https://gyazo.com/4ff66fd9c5035806f58b0d43c080069c

1 Like

Try putting the player in a sitting/platform-standing state. It seems like it might be trying to walk up itself.