I am getting the refrence error enemyis not defined.
This is my code.
– Stay in the middle and defend!
loop
enemy = self:findNearestEnemy()
if enemy then
– Either attack the enemy…
self:attack(enemy)
else
– … or move back to your defensive position.
self:attack(enemy)
end
end
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!