Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Lua Code Back to Back Help


I am getting the refrence error enemyis not defined.
This is my code.
– Stay in the middle and defend!

enemy = self:findNearestEnemy()
if enemy then
– Either attack the enemy…
– … or move back to your defensive position.


Figured it out myself ha to say local didn’t have to before weird


In the future, please format your code according to the FAQ. It helps us better understand your code as we try to help. Basically, it helps us help you!

If you have trouble finding it, click here

Also, in the future, please give more information about what happens in the game when you run your code.