Wave spawning script help

I am new to scripting.I was trying to make the enemies spawn when a dead enemy counter
drops to 0.
But at line 10 it says

“expecting ),found’+='.(BCE0044)” and

“Unexpected token: 1. (BCE0043)”

At line 12 it says “expecting :, found ‘-=’. (BCE0044)”

Here is the code.
Can anyone help me?thanks.

var enemyCounter  : int = GameObject.FindGameObjectsWithTag("Enemy").Length;
var DeadEnemies  : int = GameObject.FindGameObjectsWithTag("Dead").Length;
var defaultSpawnNumber = 10;

var waveNumber = 1;

var isSpawning = false;

function RemoveDeadZombies()
{
if (DeadEnemies +=1)
        { 
        enemyCounter -=1;
        }
}


function SpawnEnemies(wave : int)
{
        var spawnNum = (defaultSpawnNumber + 10 * (wave - 1));
        
        isSpawning = true;
        
        for(var i = 0; i < spawnNum;i++)
        {
                yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));
                
                var object : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)];
                var position : Transform = spawnPoints[Random.Range(0, spawnPoints.Length)];
                
                Instantiate(object, position.position + 
                        Vector3(Random.Range(spawnXOffsetMin, spawnXOffsetMax), 0, 
                                Random.Range(spawnZOffsetMin, spawnZOffsetMax)), position.rotation);
                
                enemyCounter++;
        }
        
        isSpawning = false;
}

function UpdateWave()
{
        waveNumber++;
        SpawnEnemies(waveNumber);
}


function Start () 
{
        SpawnEnemies(waveNumber);
}

function Update () 
{
        if(enemyCounter == 0 && isSpawning == false)
        {
                UpdateWave();
        }
}

You are doing an assignment (setting a variable to a new value) in an if statement’s condition (should evaluate to true or false).

Try this instead:

function RemoveDeadZombies() {
    // If there are more than zero DeadEnemies, remove that number from enemyCounter.
    if (DeadEnemies > 0) {
        enemyCounter = enemyCounter - DeadEnemies;
    }
}

In your line if(DeadEnemies +=1), it looks like you’re trying to say “if deadEnemies increased over the past frame.” There’s just no built-in way to check a variable against its previous value like that.

You have to maintain your own counts, by hand. Each time an enemy dies – somewhere in the part where they take damage – subtract 1 from enemies and add 1 to deadEnemies. This might change your removeDeadGuys function to simply E--; DE++;. After that change, your line in Update “if enemies==0” should work just fine. But, you wouldn’t need it there, since you only need to check for zero after each death.