When one GameObject is destroyed do something

Hello guys, I am working on make up a simple scoring script. But I have come up with an issue with add to a score once an “enemy” has been destroyed or removed form the game world

private int scoreKeeper;
public int enemyNumber;

// Use this for initialization
void Start () {
	scoreKeeper = 0;
}

void Update () {
	enemyNumber = GameObject.FindGameObjectsWithTag ("enemy").Length;

	if (enemyNumber <= 1) {
		scoreKeeper += 10;
	}
}

void OnGUI () {
	GUI.Button (new Rect (10, 60, 100, 45), string.Format("{0}", scoreKeeper));
}

This is what I came up with, but as I am sure you guys know, this does not work. When there is one enemy left the game updates the score by 10 each update so it goes up pretty fast!

I thought that something like

void Update () {
	enemyNumber = GameObject.FindGameObjectsWithTag ("enemy").Length;

	if (enemyNumber -= 1) {
		scoreKeeper += 10;
	}
}

would work add in the - but it comes up with an error.

I was trying to make it so each time an enemy was destroyed it added 10 to a number.

Thanks for any help guys!

Hi there, what if you store new and last cout and compare them like this?

        private int NewEnemyCount, OldEnemyCount, Score;

 	    private void Update()
        {
            // Get new EnemyCount every Frame 
            NewEnemyCount = GameObject.FindGameObjectsWithTag("enemy").Length;

            /* Compare New and Old EnemyCount values and if they differentiate, 
               return TRUE */
            if (NewEnemyCount != OldEnemyCount)
            {
                Score += 10;
                OldEnemyCount = NewEnemyCount; // Store last EnemyCount into Variable
            }
	    }

Hey! How about you try this:

Do not check how many enemies are left, instead, on the second line right after where you Destroy(<>); add Score +=10;

Lets just say we have something like this

    void DestroyEnemy()
    {
        Destroy(<<your enemy gameobject that you just killed>>);
        Score += 10;
    }

Another way is to attach an enemy scrip to an enemy gObject, which then adds score to the main controlling script the moment when it is destroyed, if you can show us the code that destroys an enemy, we could help a bit more.