# Help with "stillness in motion"

**URL:** <https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141>\
**Category:** Uncategorized\
**Created:** [March 30, 2016, 6:19pm UTC](https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141 "2016-03-30T18:19:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reshmi\_Naveen](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Reshmi\_Naveen](https://discourse.codecombat.com/u/Reshmi_Naveen)\
**Post date:** [March 30, 2016, 6:19pm UTC](https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141/1 "2016-03-30T18:19:49Z")

</div>

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.

```python
    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);
    }
}

```

---

<div class="post-metadata">

**Author:** ![Serg](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/serg/32/3260_2.png) [@Serg](https://discourse.codecombat.com/u/Serg)\
**Post date:** [March 30, 2016, 6:25pm UTC](https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141/2 "2016-03-30T18:25:01Z")

</div>

What shield do you have equipped?

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [March 30, 2016, 8:35pm UTC](https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141/3 "2016-03-30T20:35:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Reshmi\_Naveen](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Reshmi\_Naveen](https://discourse.codecombat.com/u/Reshmi_Naveen)\
**Post date:** [March 30, 2016, 11:25pm UTC](https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141/4 "2016-03-30T23:25:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [March 31, 2016, 12:18pm UTC](https://discourse.codecombat.com/t/help-with-stillness-in-motion/7141/5 "2016-03-31T12:18:12Z")

</div>

No problem, Reshmi\_Naveen. 😄 😄
