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

Chain lightning wont work crrectly(javascript)

while (true) {
    var green = hero.findFlag("green");
    var black = hero.findFlag("black");
    var nearest = hero.findNearestEnemy();
    if (green) {
    } else if (black && hero.isReady("cleave")) {
        // Cleave!
     if (hero.canCast("chain-lightning"), nearest && > 0){
        hero.cast("chain-lightning", nearest);
    if (hero.isReady("bash") && nearest && > 0){
    else if (nearest && > 0){
        // Attack!

my hero can only cast chain lightning once but doesn’t do anything after. how can i fix?


Well, you have several If statements without an else, and while this shouldn’t really harm your code, it’s pretty sloppy. I reccomend trying to clear it up a little bit, see if that helps.


You have a comma after hero.canCast("chain-lightning"), where there should be && instead.

1 Like

Ah, he’s right, good catch. Didn’t see that.


thanks works fine now