Please help cloudrip seige mountain mercenaries

can you guys help me to make my summoned soldiers all together attack enemy at the same time?

while True:
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    coins = hero.findItems()
    coin = hero.findNearest(coins)
    # If you have funds for a soldier, summon one.
    if > hero.costOf("soldier"):
        enemy = hero.findNearest(hero.findEnemies())
        if enemy:
            # Loop over all your soldiers and order them to attack.
            soldiers = hero.findFriends()
            soldierIndex = 0
            soldier = soldiers[soldierIndex]
            # Use the 'attack' command to make your soldiers attack.
            while soldierIndex < len(soldiers):
                hero.command(soldiers, "attack", enemy)
                soldierIndex += 1

Start by fixing the errors, you should be seeing big red error messages when you run this code. When I try to run your code I get an error on this line


because there is no coin at the very start. Check if there is a coin before trying to move towards it.
(In the same way you are checking if there is an enemy before trying to attack)

once you fix that, there is another error on this line

hero.command(soldiers, "attack", enemy)

because soldiers is a list of all of friendly units but commands have to be given to just a single soldier

once you fix that you get another error on the same line about how you can’t command Flower West. The flowers are friendly units and are in the list you named ‘soldiers’. There are a few ways to fix this, I’ll let you work that out.

Then, once you have done that you won’t have any error messages. You will still have a problem of only one soldier attacking but you will be a lot closer to solving it.