Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

The Agrippa Defense A

I’m am pretty sure my code is right but it is not working. Any help?

hile(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
        // Find the distance to the enemy with distanceTo.
        var distance = hero.distanceTo(enemy);
        // If the distance is less than 5 meters...
        if (distance < 5) {
            
        }
            // ... if "cleave" is ready, cleave!
            if (hero.isReady('cleave')) {
              hero.cleave(enemy);  
            }
            // ... else, just attack.
            else {
               hero.attack(enemy); 
            }
    }
}
1 Like

(The “W” is there in my code I just cut it off when copying it.)

On line 9, you close something, but you don’t need that. I think this is the error, so you should remove

    }

from line 9 and it should work fine.

Thank you that was the problem the whole time.

1 Like

No problem! :wink: Glad I could help.

1 Like