A coroutine is executed on a separated thread, so your code in your for won’t wait for 5 seconds and will spawn all enemies in one frame.
If you want to spawn enemies with a 5 seconds delay, you need to put the Instantiate function in a coroutine as well.
For example, something like
IEnumerator Wait()
{
for(int i = 0; i < 10; i++)
{
Instantiate(enemyObject, new Vector3(0, startPositionY, Random.Range(0f, -20f)), Quaternion.identity);
yield return new WaitForSeconds(5);
}
}
`
and your Start function will look like something like this
void Start()
{
StartCoroutine(Wait());
}
(Note that if the code you provided you forgot the "()" after your method name in StartCoroutine)
Hope this helps !
`