[Solved]The Final Kithmaze With Lua

So I trying to but i can seem to figure out what im doing wrong it wont seem to attack the enemy i can move around just fine but i also cant figure out to automate move to gems with the find nearest items function

the code I’m using currently is

while true do
       local enemy1 = hero:findNearestEnemy()
       self:moveRight()
       self:moveUp()
       self:attack(enemy1)
       self:attack(enemy1)
       self:moveRight()
end

Even i don’t know lua, but you should need loop i guess

do you mean the while true do part because i do have that it just didn’t show up when i put backticks

So, screen shot? pls?

Screenshot (8)

1 Like

I think you don’t need end

Does it show where the errors?

it move right then up but does not attack the enemy

even though the enemy is in the hero’s sight by then

try making another move to the right before attacking the enemy

it ends the same way

I don’t know then, i have to sleep now, bye

okay thanks for the help anyway

You can @Jason_king_lin , if you want more help

Yeah, i found the problem

Where???
Where is the problem

The thing is, you (@TheCelestial ) have to define enemy right before attacking, and the line i told you to add, you should remove it, and then make sure you go down twice after moving right after attacking the enemy

So put the “findEnemy” function “on” the attack method, right?
@Aya

i dont understand, what s/he should do is move right, then up, then define enemy local enemy = hero:findNearestEnemy() and then attack the enemy twice, then move to the right, then go down twice and then move up

Maybe he/she is a beginer?