# Failing commands

**URL:** <https://discourse.codecombat.com/t/failing-commands/6717>\
**Category:** Uncategorized\
**Created:** [February 9, 2016, 2:02am UTC](https://discourse.codecombat.com/t/failing-commands/6717 "2016-02-09T02:02:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nogard1024](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@nogard1024](https://discourse.codecombat.com/u/nogard1024)\
**Post date:** [February 9, 2016, 2:02am UTC](https://discourse.codecombat.com/t/failing-commands/6717/1 "2016-02-09T02:02:58Z")

</div>

I am on Kithgard Brawl 4 and my code is giving me an error: Hero placeholder needs something to command.

```python
# Survive the waves of ogres.
# If you win, the level gets harder, and gives more rewards.
# If you lose, you must wait a day to re-submit.
# Each time you submit gives a new random seed.
self.cast("invisibility", self)
self.summon("peasant")
def commandSoldiers(enemies):
    for friend in self.findFriends():
        nearest=friend.findNearest(enemies)
        if friend and nearest:
            self.command(friend, "attack", nearest)

loop:
    palisades=[{"x":45,"y":36},{"x":40,"y":32},{"x":37,"y":35},{"x":38,"y":36}]
    for palisade in palisades:
        peasant=self.findByType("peasant")
        if peasant:
            self.command(peasant, "buildXY", palisade)
    commandSoldiers(self.findEnemies())
    item = self.findNearest(self.findItems())
    if item:
        self.move(item.pos)
        continue
    if self.gold>=20:
        self.summon("soldier")
    nearest = self.findNearest(self.findEnemies())
    if self.isReady("invisibility"):
        self.cast("invisibility", self)
        continue
    if self.hasEffect("hide"):
        continue
    if nearest:
        if self.isReady("chain-lightning"):
            self.cast("chain-lightning", nearest)
            continue
        distance=self.distanceTo(nearest)
        if (distance > 6):
             self.move(nearest.pos)
        else:
             if self.isReady("cleave"):
                  self.cleave(nearest)
                  continue
            self.attack(nearest)

    

```

---

<div class="post-metadata">

**Author:** ![Hinkle](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hinkle/32/3967_2.png) [@Hinkle](https://discourse.codecombat.com/u/Hinkle)\
**Post date:** [February 9, 2016, 2:47am UTC](https://discourse.codecombat.com/t/failing-commands/6717/2 "2016-02-09T02:47:34Z")

</div>

`peasant=self.findByType("peasant")`  
Returns an array of peasant objects (even if there is only 1)  
You need to command `peasant[0]`

---

<div class="post-metadata">

**Author:** ![RobAnybody](https://avatars.discourse-cdn.com/v4/letter/r/7ba0ec/32.png) [@RobAnybody](https://discourse.codecombat.com/u/RobAnybody)\
**Post date:** [February 9, 2016, 8:27am UTC](https://discourse.codecombat.com/t/failing-commands/6717/3 "2016-02-09T08:27:24Z")

</div>

maby

> self.command(peasant, ‘buildXY’, “palisade”, palisade.x, palisade.y)
