Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Found an expression But expected a Statement: While


I program on LUA
In the level of “a mayhem of munchkins” i wrote this code :

    local enemy=self:findNearestEnemy 
    self : attack (enemy)

But it tells me "Found an expression But expected a Statement: While"
Please Guys Help me !!
Thank you :smile:


maybe check the existence of enemy by

if enemy:

Also… format your code in radiant, harmonious formatting so everyone can easily read it as per FAQs



Hello, Safouene, and welcome. Please read the FAQ prior to your next post, so that you learn how to format our code properly. I’ve done it for you this it, but do so yourself in the future.

findNearestEnemy is a method. It requires a pair of parentheses to call properly. Also, I don’t think that you are allowed spaces between self, the colon, and the input argument.