Decoy drill (hero.gold is not working)

I’m having problems with decoy drill. My code is:

# We are field testing a new battle unit: the decoy.
# Build 4 decoys, then report the total to Naria.

decoysBuilt = 0
while True:
    coin = hero.findNearestItem()
    
    if coin:
        # Loot the coin!
        hero.moveXY(coin.pos.x, coin.pos.y)
        pass
    # Each decoy costs 25 gold.
    # Know when you have more than 25 gold with hero.gold
    if hero.gold >= 25:
        hero.buildXY("decoy", hero.pos.x - 5, hero.pos.y)
        # Keep a count of decoys you built as you go along.
    decoysBuilt += 1
    if decoysBuilt == 4:
        # Break out of the loop when you have built 4.
        break
        pass
    
hero.say("Done building decoys!")
hero.moveXY(14, 36)
# Go to Naria and say how many decoys you built.
hero.moveXY( 14, 36)
hero.say(decoysBuilt)

I press run to test the code and it is skipping the hero.gold part and doing the decoysBuilt part instead.
I does this after about 5 seconds after the level starts.

You should only increment decoysBuild when you build a decoy, not every tick of the while-loop.

Okay i see. It wasn’t a part of the if statement. Every time i have some code that doesn’t work it always turns out to be some small mistake.