Stop Spawn Instantiate

I’m trying to set up a spawn function that will not spawn more than a maximum number of enemies. When I run my game, it spawns enemies until it’s blue in the face, totally disregarding my limit. I’m super new to Unity and C#, so I’m not really sure what I’m overlooking.

using UnityEngine;
using System.Collections;

public class SpawnEnemy : MonoBehaviour {

	private GameObject[] enemyCount;
	private int howManyEnemies;
	public int enemyMax;
	public GameObject enemyType;
	public Transform spawnPoint;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		enemyCount = GameObject.FindGameObjectsWithTag ("Enemy");

		howManyEnemies = enemyCount.Length;

		if (howManyEnemies < enemyMax) {
			Instantiate (enemyType, spawnPoint.position, spawnPoint.rotation);

		}

		else {
			return;
		}

	}
}

Thanks in advance!

Well, the code looks fine to me! The only thing I can think of is that any new enemies that are getting spawned in are not being tagged as ‘Enemy’ - is this something you’ve checked? Try adding a Debug.Log(enemyCount.Length) to see if things match up.