Infinite loop of death

So I’m trying to make a knocked down system
But the player dies, stays dead and when it revives he dies over and over again
He doesn’t respawn, he just gets knocked, gets up and gets knocked again.

Another thing it was doing before was that the player was reviving and becoming immortal

I messed with this code so much I don’t even know what I’m doing

Any help?

game.Players.PlayerAdded:Connect(function(player)


	player.CharacterAdded:Connect(function()

		repeat wait() until player.Character
		local Character = player.Character
print("Found Character")
		
		




		

		print(Character.Name)

		while true do
			wait(0.5)
			repeat wait(0.5) 
			until Character.Humanoid.Health <= 10
			
			Character.HumanoidRootPart:SetNetworkOwner(nil)
			print("MADE HHUMANOID 0")
			Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead,false)
			Character.Humanoid:ChangeState(Enum.HumanoidStateType.Dead)
print("Ded")
			local knocked = Instance.new("BoolValue")
			knocked.Name = "Knocked"
			knocked.Parent = Character
			game.Debris:AddItem(knocked,10)

			

			local hit = Instance.new("BoolValue")
			hit.Name = "Hit"
			hit.Parent = Character
			game.Debris:AddItem(hit,10)


			Character.RagdollTrigger.Value = true
			wait(10)
			

			Character.Humanoid.Health = Character.Humanoid.Health + 15
			
			Character.RagdollTrigger.Value = false
			Character.HumanoidRootPart:SetNetworkOwner(player)
			Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead,true)
			
	
			end





	end)

end)

you don’t need a while true do, repeat wait() will repeat wait() until the requirement is met, if they are dying its most likely because someone 1 shot them, so it played when they died if it makes sense, your looking for if their health is below 10, you have a 0.5 second delay, meaning the code played after they died, and because its in a while true loop it keeps repeating it over and over causing lag and malfunctions