loop
local enemy1 = self:findNearestEnemy
if enemy1 then
self:attack(enemy1)
self:attack(enemy1)
end
its not working please help
loop
local enemy1 = self:findNearestEnemy
if enemy1 then
self:attack(enemy1)
self:attack(enemy1)
end
its not working please help
Please format your code with radiant, harmonious formatting
as described in the FAQ. Also, phrases like âitâs not working.â and âplease helpâ arenât helpful. In future please describe what is or isnât happening. For example, are there any error messages?
(Also, there are several languages available in CodeCombat, and it is often helpful to say what language youâre using.)
That said, Iâve encountered this particular problem before:
local enemy1 = self:findNearestEnemy
needs to read
local enemy1 = self:findNearestEnemy()
For some reason the Lua code for findNearestEnemy doesnât have the brackets. Iâve updated it, but the change wonât take effect until one of the owners approves it.
Deatrix the error messaage says "Found an expression but as expected: While
and there is not âWhileâ?
Mod edit: Please donât swear
I honestly donât know why it gives that particular error (at least itâs consistent), but it will work if you add the brackets.
Thanks it worked I had to tweak it because I accidentally had a space in a area