# [Solved]What does the duck mean?

my code:

``````# You'll need good strategy to win this one!
# Your clone will have the same equipment you have!
# But, they're not very skilled at using special powers.
while True:
enemy = hero.findNearestEnemy()
if enemy.distance < 10:
hero.attack(enemy)
if hero.health < hero.maxHealth/2:
hero.jumpTo(36,53)
``````

this is where the error is:

``````  if enemy.distance < 10:
``````

thanks moon!

Well, firstly try rewriting this line of code,

what line?
(0000002)

I gtg to sleep.Bye!sorry

its ok we all have to sleep.

Uhhhh, itâ€™s supposed to be `hero.distanceTo(enemy)`â€¦ I think you should have already learned this in the forest.

1 Like

And the argument needs to be a position, so like:
Javascript:

``````{x: 36, y: 53};
``````

Python:

``````{"x": 36, "y": 53}
``````

oh ok iâ€™ll try that
i havenâ€™t played in a while so i forgot

or if you have vectors.

``````Vector(36,53)
``````

Bruh, he isnâ€™t even in the Mountains yet, how would he know about vectors???

idk but u can do,
while loops, for loops and if/else and while True loops with no programiticon

True, but you wouldnâ€™t be able to see how if you didnâ€™t remember.

donâ€™t get off topic.

Well technically itâ€™s not off-topic, but thats good idea.

The problem is that you havenâ€™t checked if the enemy exists.

And what moonwatcher said.

i did here
(2000000)

you still need to do `enemy && hero.distanceTo(enemy)` or `enemy and hero.distanceTo(enemy)` to check if the enemy exists or it will throw an error.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.