# Bank raid help me!

I need help!

After my hero is done collecting coins at first, it defeats its second enemies, it stops. Here is my code:

``````while True:
enemies = hero.findEnemies()
# enemyIndex is used to iterate the enemies array.
enemyIndex = 0
# While enemyIndex is less than len(enemies)
while enemyIndex < len(enemies):
# Attack the enemy at enemyIndex
enemy = enemies[enemyIndex]
hero.attack(enemy)
# Increase enemyIndex by one.
enemyIndex += 1
coins = hero.findItems()
# coinIndex is used to iterate the coins array.
coinIndex = 0
while coinIndex < len(coins):
# Get a coin from the coins array using coinIndex
coin = coinIndex
# Collect that coin.
item = hero.findNearestItem()
hero.moveXY(item.pos.x, item.pos.y)
# Increase coinIndex by one.
coinIndex += 1
``````

A few details to clean up, although this didnâ€™t directly impact the problem. What hero and gear do you have? I found that the Ring of Thorns can cause some problems on this level.

To use the index for the array it should be: variable = array[index]

``````    while coinIndex < len(coins):
# Get a coin from the coins array using coinIndex
coin = coinIndex # look at how it was done with enemy
``````

Then use that variable for the move command instead of creating a new variable.

1 Like

This is my stuff.

I did it! thanks for the help

Nevermind, it stopped working

First do what Brooksy said, but even then it still doesnâ€™t work sometimes and the hero just says â€śBut itâ€™s dead!â€ť. To solve this simply put: `if enemy.health > 0:` before you attack the enemy to make sure itâ€™s still alive.
-Danny

When I do that it just shows the X.

It worked! I finally finished bank raid. Thanks for the help.

1 Like

Hello Iâ€™m new to this.

Hi @EpicCoder999, welcome to the CodeCombat discourse!
If you need help with your code please post it, formatted as explained here:

Thanks
Danny

Can someone buff the level 66 items please? The Crypt Key costs 3100 gems and only have the power of the precious. The boots of flying costs about 500 moregems than boots of leaping and only increases speed by 0.5m/s, the Amber sense stone sux and I have to buy it to play this level I think. The hammers are only the strength of the stone hammer.

Oh yes, hereâ€™s my code:

``````while True:
enemies = hero.findEnemies()
# enemyIndex is used to iterate the enemies array.
enemyIndex = 0
# While enemyIndex is less than len(enemies)
while enemyIndex < len(enemies):
# Attack the enemy at enemyIndex
enemy = enemies[enemyIndex]
hero.attack(enemy)
# Increase enemyIndex by one.
enemyIndex += 1
coins = hero.findItems()
# coinIndex is used to iterate the coins array.
coinIndex = 0
while coinIndex < len(coins):
# Get a coin from the coins array using coinIndex
coin = coins[coinIndex]
# Collect that coin.
hero.moveXY(coin.pos.x, coin.pos.y)
# Increase coinIndex by one.
coinindex += 1
``````

my hero canâ€™t collect coins after it collects the first one!

``````        # Increase coinIndex by one.
coinindex += 1
``````

Hi,
Iâ€™m new to this as well :).
Try using a capital I in coinIndex.

1 Like

Hi @jka2706, welcome to the CodeCombat Discourse!
Good spot.
Danny

1 Like

But you get to fly.
In case you didnâ€™t know level 66 items are still in development, thatâ€™s why their abilities are a little bit unbalanced.
Danny

Yay it worked thx i mean the code (20 chars so annoying)

oh might be a glitch cause it says im required to use them.

OMG the morningâ€™s edge only have 80 dps, it should be unlocked at level 15. nvm i will get sword of the forgotten instead, teample guard way too expenise

@nick can you reset my gems please? my username is ProGamer247, if the reset deletes the heros i got when im a subscriber, then dont reset cuz i got okar and omarn

Why do you want nick to reset your gems?
He probably wonâ€™t see this post for a while, so thereâ€™s not much point asking him.
Danny