Hey there! Writing my R6 ragdoll script currently but when setting the mode to physical or trying to change it the state won't change at all. Any ideas as to what I do or what I did wrong?

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local DeadPos = CFrame.new(0, 0, 0)

		local Humanoid = Character:WaitForChild("Humanoid")

		Humanoid.BreakJointsOnDeath = false
		Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)

		Humanoid.Jumping:Connect(function()
			
			DeadPos = Character.HumanoidRootPart.CFrame	

			Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

			for _, Limb in pairs(Character:GetDescendants()) do
				
				if Limb:IsA("Motor6D") then
					local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")

					Attachment0.CFrame = Limb.C0
					Attachment1.CFrame = Limb.C1
					
					Attachment0.Parent = Limb.Part0
					Attachment1.Parent = Limb.Part1

					local Joint = Instance.new("BallSocketConstraint")
					
					Joint.Attachment0 = Attachment0
					Joint.Attachment1 = Attachment1
					
					Joint.Parent = Limb.Part0

					Limb:Destroy()
					end
				end
		end)
	end)
end)