You can use a global variable counter as a condition i.e. spawn enemy while global var less than 20 and add 1 to global var every time one spawns. You could also use the count of the enemy objects, i.e. if enemy.count < 20 then spawn, this counts the number of enemies that exist, but this would only be used if you had a max of 20 at any one time and destroying them affected the count, I don't think that applies here but it's useful to know.