# Decoy Drill Issues - Javascript

**URL:** <https://discourse.codecombat.com/t/decoy-drill-issues-javascript/2581>\
**Category:** Adventurer\
**Created:** [February 4, 2015, 7:31pm UTC](https://discourse.codecombat.com/t/decoy-drill-issues-javascript/2581 "2015-02-04T19:31:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevshand](https://avatars.discourse-cdn.com/v4/letter/t/aeb1de/32.png) [@trevshand](https://discourse.codecombat.com/u/trevshand)\
**Post date:** [February 4, 2015, 7:31pm UTC](https://discourse.codecombat.com/t/decoy-drill-issues-javascript/2581/1 "2015-02-04T19:31:56Z")

</div>

I am having trouble with Decoy Drill. I am collecting way too much gold before building a decoy. If I take out the pice of code that says totalGold=0; after building a decoy, my guy simply stops.

Thoughts?

```python
var decoysBuilt = 0;
var totalGold = 0;
loop {
  
    var coin = this.findNearestItem();
    this.moveXY(coin.pos.x, coin.pos.y);
    var value = coin.value;
    totalGold = totalGold + value;
    
    
    if (totalGold >= 25) {
        this.buildXY("decoy", this.pos.x, this.pos.y);
        decoysBuilt = decoysBuilt + 1;
        totalGold=0;
    }
    
    if (decoysBuilt >= 4) {
        break;
    }
        
}

this.say("Done building decoys!");
// Go to Naria and say how many decoys you built.
this.moveXY(14, 36);
this.say("I have built "+decoysBuilt+" decoys.");

```

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [February 4, 2015, 7:39pm UTC](https://discourse.codecombat.com/t/decoy-drill-issues-javascript/2581/2 "2015-02-04T19:39:30Z")

</div>

pro tip. put three of these characters on a line by itself both before and after your pasted code. `

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [February 4, 2015, 7:48pm UTC](https://discourse.codecombat.com/t/decoy-drill-issues-javascript/2581/3 "2015-02-04T19:48:22Z")

</div>

Try using the `this.gold` from your sense stone on this one, since you can’t count the gold you incidentally pick up on the way to get your target coin just by summing `coin.value` numbers.
