[SOLVED] Mountain Mercaneries Help!

I need help with this i have been stuck for around 20 minutes

here is my code

# Gather coins to summon soldiers and have them attack the enemy.

while True:
    coin = hero. findNearestItem()
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    hero.move(coin.pos)
    hero.say("I need coins!")
    
    # If you have funds for a soldier, summon one.
    if hero.gold > hero.costOf("soldier"):
        hero.say("I should summon something here!")
        
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        # Loop over all your soldiers and order them to attack.
        while True:
            # Use the 'attack' command to make your soldiers attack.
            #hero.command(soldier, "attack", enemy)
            if soldier:
                hero.command(soldier, "attack", enemy)

Change your category to #level-help please, @TEO

Summon a soldier like it says here:

So you should put:

Increment soldierIndex by doing soldierIndex += 1

@TEO next time when you’re asking for help on certain levels, you can look through the hints section if you haven’t done so, and it’s located on the top right corner of the level screen.

…

That also works too

I tried that and it doesn’t help i also summoned but i only command one at a time for some reason?

I will post my code again this time updated look

# Gather coins to summon soldiers and have them attack the enemy.

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

and also i don’t know how to change it to lvl help

Delete this. It slows you down.

Here put:

if soldier:
                    hero.command(soldier, "attack", enemy)
                soldierIndex += 1

Drop the while True, and put while there

also you don’t need hero.jumpTo use move or moveXY jumping slows you down by a lot

Here put:

(20 characters)

you also don’t need the hero saying i need coins

change the while true at the bottom to while soldierIndex < len(soldiers):

and add this below the while
soldier = soldiers[soldierIndex]

Yeah. I was about to say that. Thanx @Destroyer5023

np(i hate this 20 chars :rage:)

Did you solve it? @TEO
Lydia