Kelvintaph Crusader help!?

I cant figure out why the minions on top dont survive, help plz?

Could you tell us what the error is, the level name, and perhaps a screenshot of the error?

My hero gets out safely, but the top part doesnt kill the enemies

So this is your code

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
def LowestFriend():
    lowestfriend = None
    lowestHealth = 9999
    friends = hero.findFriends()
    for friend in friends:
        if friend.health < friend.maxHealth and friend.health < lowestHealth:
            lowestfriend = friend
            lowestHealth = friend.health
            return lowestfriend
            
def commandPaladin(paladin):
    if paladin.canCast("heal"):
        hero.command(paladin, "cast", "heal", LowestFriend())
    elif paladin.health < 200:
        hero.command(paladin, "shield")
    else:
        witches = hero.findByType("witch")
        for witch in witches:
            if witch:
                hero.command(paladin, "attack", witch)
                
if hero.canCast("chain-lightning", 'Trogdor'):
    hero.cast("chain-lightning", 'Trogdor')
    
def commandTroops():
    friends = hero.findFriends()
    paladins = hero.findByType("paladin")
    enemies = hero.findEnemies()
    witches = hero.findByType("witch")
    enemies = hero.findEnemies()
    ogre = hero.findByType("ogre", hero.findEnemies())
    for friend in friends:
        if friend.type != "paladin":
            if ogre.health > 0:
                hero.command(friend, "attack", "Oni")
            elif ogre.health <= 0:
                if 'Rusty':
                    hero.command(friend, "attack", "Rusty")
                elif 'Skully':
                    hero.command(friend, "attack", "Skully")
                    
        else:
            commandPaladin(friend)

def EscapeTimeBoys():
    friends = hero.findFriends()
    for friend in friends:
        if hero.wait() > 22:
            hero.command(friend, "move", {'x': 32, 'y': 59})
            hero.command(friend, "move", {'x': 50, 'y': 57})
            hero.command(friend, "move", {'x': 50, 'y': 39})
        if hero.wait() > 30:
            hero.command(friend, "move", {'x': 78, 'y': 40})
            
while True:
    commandTroops()
    EscapeTimeBoys()
    catapult = hero.findNearest(hero.findByType("catapult"))
    brawler = hero.findNearest(hero.findByType("brawler"))
    if brawler and hero.distanceTo(brawler) >= 18:
        hero.moveXY(hero.pos.x + 5, hero.pos.y)
    elif brawler:
        hero.moveXY(hero.pos.x - 2, hero.pos.y)
    elif catapult:
        hero.attack(catapult)
    else:
        hero.moveXY(78, 14)

This is run only in case it goes into the if-statement
So might as well push it back outside the if statement (because otherwise the functuon is pointless as it wont return anything and might cause an error)

As for everything inside the function, you would want to add an if-statemnt to check if there is a paladin in the first place

You can also instead add the if statement when you are calling this function

Might as well check for a friend here

This will return a list not only one ogre

So all this should be in a for loop to check for every ogre or you can find the nearest/healthiest/least healthy ogre