Kithgard Brawl glitch

It seems that on line 8, evem though I defined enemy, it says that I need something to cast upon. here is my code

    enemy = self.findNearest(self.findEnemies())
    if self.canCast("drain-life", enemy):
        self.cast("drain-life", enemy) #(line 8)
    if self.distanceTo(enemy) < self.attackRange:
    if self.canCast("fear"):

I removed the comments
also, I wont cast fear, attack, or do anything else

You don’t check if there is an enemy in the first place. At the very beginning, it’s quite possible that there is none, so enemy is null. Therefore, you don’t have anything to cast upon.

Also, you have to cast "fear" on a target; it doesn’t work if you don’t specify a second argument.