How to instantiate multiple objects with intervals every X seconds?

i am making a game with some MOBA mechanics. i have a spawner that gives me 5 enemies at a 1 second interval from one another. but as soon as i kill any enemy a new one spawns. i am trying to make it so that the “Wave” of enemies spawns every 5 seconds.

on the other hand i have the enemies and whenever the player runs to them, they just float away instead of move to the castle.

the enemies spawn and move to the castle, but if a player kills any, a new one spawns right away and if the player just walks to them, they just float away.

any suggestions?

Do you have an example of your current code? @zoraDra