Sacred Statue (Python)

I’m not sure what happened or why, but the code at the end of this level worked the first 4 times I ran it. Now, it’s giving me an error.

while True:
    enemy = hero.findNearestEnemy()
    friend = hero.findNearest(hero.findFriends())
    friendPos = {'x':friend.pos.x, 'y':friend.pos.y}
    if friend and hero.distanceTo(friend) > 5:
        if enemy and hero.distanceTo(enemy) < 5:
            if hero.isReady("bash"):

Is it possibly a gear problem? Wrong glasses? Wrong boots?

Really can’t figure this out and I’ve been at this on and off for days.

1 Like

I would guess that all your friends are dead at the end of it, and you’re trying to access a propert of null.

(Cannot read property ‘pos’ of null), as in you’re trying to do: (null).pos, and null isn’t an object, so it doesn’t have properties.

Use if(friend) before friendPos = friend.pos.x.

1 Like

Hi @Rafi_Kaufman, please do not give away solutions, it is against the forum’s rules.

~ Syldar