It has to do with indentations. The ‘while enemyIndex’ loop, needs to be indented, so as to make it an inner loop, or a child loop (member), of the outer ‘while true’ loop.
- Just to explain, the terms ‘inner loop’ and ‘child loop’ are often used interchangeably. They both imply that there is another loop in the hiarchy (above) that they are working for.
- This other loop is referred to either the ‘parent loop’, or the ‘outer loop’…all of these terms are correct, it’s just a matter of preference, how you learned, etc.
You will also have at least one other issue, but let’s address that, once you get this one fixed…a bit less confusing that way.