Help with "stillness in motion"

I need help in “stillness in motion” . Here is my code. when i run this code it says that " this.shield();" is not a function. and my hero dies. What am i doing wrong? Please help. Thank you.

    var enemy = this.findNearestEnemy();
    // If there is an enemy, then...
    if(enemy) {
        var distance = this.distanceTo(enemy);
        
        // Create a distance variable with distanceTo.
       
        // If the distance is less than 5 meters, then attack.
                if(distance < 5){
                  this.attack(enemy);
        }
        
        // Else (the enemy is far away), then shield.
                 else{
                    this.shield();
                 }
                               
    // Else (there is no enemy)}...
   }  else {
        // ... then move back to the X.
        this.moveXY(40, 34);
    }
}

What shield do you have equipped?

Also, just for reference use this.isReady() for the shield ability.

Thank you guys. I did not realize that my hero did not have a shield. so i changed my hero, equipped her with shield and sword, and i got through.

No problem, Reshmi_Naveen. :smile: :smile: