Whenever I try to attack the enemy it always says “Line 11: ArgumentError: distanceTo’s argument target should have type object, but got function. Find the distance to a target unit.” My code is below.
# Be the first to 100 gold!
# If you are defeated, you will respawn at 67% gold.
enemy = hero.findNearestEnemy
while True:
# Find coins and/or attack the enemy.
# Use flags and your special moves to win!
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x,item.pos. y)
if enemy:
if hero.distanceTo(enemy) < 5:
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)