Need help (Range Finder)

Level 8,Wood Forest
Incorrect code:

enemy4 = Gorgnub
distance4 = hero.distanceTo(enemy4)
hero.say(distance4)

Thanks for reading!!

You can’t copy and paste your code?

1 Like

It seems to me that your code is correct. You can’t pass the level?

1 Like

…,it can’t attack enemy 4

enemy4 = Gorgnub
distance4 = hero.distanceTo(enemy4)
hero.say(distance4)

Okay

Use parentheses around Gorgnub.

1 Like

It should work after that.

1 Like

wrong,it gives error

Gorgnub should be a string of characters. A string of characters is defined by quotes ( " ").

As your code is written, I dont think the game can figure out who Gorgnub is, try to make sure it understands that Gorgnub is a string !

1 Like

That’s what I said isn’t it?

1 Like

Try this. Gorbnub is a name, so therefore it is a string.

enemy4 = "Gorgnub"
distance4 = hero.distanceTo(enemy4)
hero.say(distance4)
1 Like

oops.i typed it wrong.in the game level i also typed it but it is still wrong.

What? What are you saying?

1 Like

Parentheses are ( )

Quotes are " "

1 Like

still wrong
still wrong

can you give your full code?

1 Like

put your preformatted text so, we can read your code better.
you can do that by using </> at the top of your text like this:

while True:
    horse = hero.findFriends()
    if horse:
        friend = hero.findNearestFriend()
        hero.attack(friend)
1 Like

Right. Sorry about that.

1 Like
while True:
    horse = hero.findFriends()
    if horse:
        friend = hero.findNearestFriend()
        hero.attack(friend)

ok?

He’s just showing you how to format it, that’s not the code you need. What is your current code?