Stranded in the dunes coding bugs

I am trying to do the level “Stranded in the dunes” and my character keeps shooting at the side of the map at some point in the level! Could you please help me with my code?

loop:
flag = self.findFlag(“green”)
healflag = self.findFlag(“violet”)
enemy = self.findNearestEnemy()
if flag:
self.pickUpFlag(flag)
if enemy:
self.attack(enemy)
pass
if healflag:
self.pickUpFlag(healflag)
self.heal(self)

P.S for some reason my code doesn’t line up here but it does in the level

Some other things that are happening: The yaks sometimes teleport back to the far right of the stage and charge again, My hero just runs to the far right of the stage even if I put a flag down to stop him , sometimes when the hero is attacking he will try to move to a different enemy and then just run into an enemy over and over until he dies and finally sometimes the bullets I fire bounce off of stone and people and even sometimes yaks. I don’t know why these things are happening and I think it may be from my code. Please help!

Please post your code according to the FAQ. It gives a better understanding of what’s going wrong. And also, does it say anything like maybe “fix your code” or “error on line 2” or something. that would help a little more. As of now, I am not sureof what is wrong as I have have never played this level. But i will try to help you the best I can.

Cheers! :beers: