Why are unlimited enemies spawned?

This is how my enemies are gettings spawned: (function)

Screenshot by Lightshot (Level Blueprint)

And this is how the function is being called:

Screenshot by Lightshot (Character Blueprint)

Now when the enemy dies, ‘EnemyAmount’ is being reduced by exactly 1 and my level is supposed to spawn another AI then (enemy) but instead it spawns like 4 enemies every second for unlimited seconds.

Does anyone know why?

considering each time you kill enemy it reduces enemy count by one there is a logical error as follows

1.timer spawns 4 enemies

2.enemy count is 4 because 4 enemies

  1. player kills 1 enemy player count decreases by 1 and becomes 3

  2. timer sees player count is less than 4 I.e 3 so it spawns another enemy

repeat from point 2

either stop timer after 4 spawns or use seperate variables to track kills

This auto list item feature of answer hub is pretty bad and annoying

What I might say is what you meant, and I know what’s the problem:

Since the SpawnEnemy is in my AI Blueprint it spawns more AIs of the same class so all of them have the SpawnEnemy function again and thus they won’t stop cloning. With help of Jacky I solved the problem (Call variable in gaminstance)

Thank you for the answer though