Why is my enemies health not increasing?

So I tried by best to write a script that makes my enemies health go up every 5 wave or so. It works for the two first parts of the script but then resets to its original health.

	public WaveSpawner waveSpawner;
	public bool healthAdded1 = false;
	public bool healthAdded2 = false;
	public bool healthAdded3 = false;
	public bool healthAdded4 = false;
	public bool healthAdded5 = false;
	public bool healthAdded6 = false;

        void Update()
        {

         if (waveSpawner.waveIndex >= 2){

			if (healthAdded1 != true) {
				health += (10);
				maxHealth = (110);
				enemyHealthBar.valueMax += (10);
				enemyHealthBar.valueCurrent += (10);
				healthAdded1 = true;
				return;
			}
			return;
		}

		if (waveSpawner.waveIndex >= 4){

			if (healthAdded2 != true) {
				health += (40);
				maxHealth = (150);
				enemyHealthBar.valueMax += (40);
				enemyHealthBar.valueCurrent += (40);
				healthAdded2 = true;
				return;
			}
			return;

		}
		if (waveSpawner.waveIndex >= 20){

			if (healthAdded3 != true) {
				health += (50);
				maxHealth = (200);
				enemyHealthBar.valueMax += (50);
				enemyHealthBar.valueCurrent += (50);
				healthAdded3 = true;
				return;
			}
			return;
		}
		if (waveSpawner.waveIndex >= 30){

			if (healthAdded4 != true) {
				health += (100);
				maxHealth = (300);
				enemyHealthBar.valueMax += (100);
				enemyHealthBar.valueCurrent += (100);
				healthAdded4 = true;
				return;
			}
			return;
		}
		if (waveSpawner.waveIndex >= 40){

			if (healthAdded5 != true) {
				health += (50);
				maxHealth = (350);
				enemyHealthBar.valueMax += (50);
				enemyHealthBar.valueCurrent += (50);
				healthAdded5 = true;
				return;
			}
			return;
		}
		if (waveSpawner.waveIndex >= 45){

			if (healthAdded6 != true) {
				health += (60);
				maxHealth = (410);
				enemyHealthBar.valueMax += (60);
				enemyHealthBar.valueCurrent += (60);
				healthAdded6 = true;
				return;
			}
			return;
		}

        }

The first healthAdded1 bool is being checked after wave 2, but healthAdded2 never gets activated.
Thoughts? Is there a better way to do this?
Thanks in advance :slight_smile:

Try removing all of the returns. It might be causing your update to break once you’ve gone passed the first If statement. You don’t need return in if statements for the most part anyway, if at all

edit:

It also could be that you have two different statements changing values at the same time.

When healthAdded1 is true, you have maxhealth = 110, but when healthAdded2 is true, you have maxhealth = 150.

When BOTH of these statements is true, maxhealth is going to equal 110 and then 150, and so on

if (waveSpawner.waveIndex >= 2){
             if (healthAdded1 != true) {
                 health += (10);
                 maxHealth = (110);
                 enemyHealthBar.valueMax += (10);
                 enemyHealthBar.valueCurrent += (10);
                 healthAdded1 = true;
                 return;
             }
             return; //This will aways return  with "waveIndex >= 2", remove this return or change to "waveIndex ==2"
         }