Leave it to cleave. My character died before. Help me find the error

# The function defines a parameter called target
def cleaveWhenClose(target):
    if hero.distanceTo(target) < 5 and hero.isReady("cleave"):
        pass
        # Put your attack code here
        # If cleave is ready, then cleave target
        hero.cleave(target)
        # else, just attack target!
    else:
        hero.attack(target)    

# This code is not part of the function.
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # Note that inside cleaveWhenClose, we refer to the enemy as target.
        cleaveWhenClose(enemy)```

Your code is correct. Make sure you have the right equipment. (Good armor? Correct sword? etc.)

1 Like

I have to spend gem buying equipment?

Some equipment can be obtained for free in certain levels (the Long Sword itself is one of those items), but most you have to get with gems.

1 Like

Adding on to what @Hellenar said, make sure that you have at least 144 health for that level. I think that is the mininum requirment.