Lua Code Back to Back Help


#1

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


#2

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


#3

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.