Welcome welcome @Issi to the forum! It is a lovely place where you can share all kinds of stuff (appropriate of course), share bugs, and even get assistance for code! We suggest that you review this topic which shows all essentials of this board! And we suggest you review this topic which shows how to post your code correctly! Thanks!!
Try writing friend = hero.findNearestFriend()
and enemy = hero.findNearestEnemy()
at the top of the while true loop? Or maybe try restarting the level and writing the code again.
Lydia