The Trials stuck

I need some help with my code. He just stands there? Any ideas?

loop:
    closestEnemy = None
    minDistance = 150
    enemyIndex = 0
    enemies = self.findEnemies()
    mushrooms = self.findItems()
    mushroom = self.findNearest(mushrooms)
    if closestEnemy:
        currentEnemy = enemies[enemyIndex]
        enemyIndex += 1
        currentDistance = self.distanceTo(currentEnemy)
        if closestEnemy:
            while closestEnemy.health > 0:
                if closestEnemy.health > 150:
                    if self.isReady("power-up"):
                        self.powerUp()
                    elif self.isReady("bash"):
                        self.bash(closestEnemy)
                    else:
                        self.attack(closestEnemy)
                else:
                    self.attack(closestEnemy)
        elif mushroom:
            self.move(mushroom.pos)
    elif self.pos.y > 100:
        if self.pos.x > 90:
            self.moveXY(75, 125)
        if self.pos.x < 40:
            self.moveXY(100, 125) 
        if self.pos.x > 50 and self.pos.x <= 90:
            newEnemy = self.findNearest(self.findEnemies())
            if not newEnemy:
                self.move({"x": 55, "y":115})
                self.moveXY(27, 121)
                self.moveXY(56, 122)
                self.moveXY(45, 96)
                self.move({"x": 45, "y":70})
                self.moveXY(80, 70)
            else:
                pass

Please indent your code correctly by highlighting it and clicking the </> button. Reading the FAQ before posting can be helpful. :wink:

Oh sorry I didn’t know how to indent and I am really busy

I see your problem. You define closestEnemy as None, then never redefine it as anything else. For this reason, closestEnemy is never true, so the if-statement never runs.

oh oops thank you so much I’ll fix that and see if it works.