A Mayhem of Munchkins

loop
local enemy1 = self:findNearestEnemy
if enemy1 then
self:attack(enemy1)
self:attack(enemy1)
end

its not working please help :frowning:

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