Backwoods Forest-Wild Horse Level

I’m trying to fix my code…not sure why this horse.pos.x is not working

    # How do you find the nearest friendly unit?
    # horse = ?
    horse = "Wild Horse T"
    if horse:
        x1 = horse.pos.x - 7
        x2 = horse.pos.x + 7
        if x1 >= 1:
            # Move to the horse's y position but use x1 for the x position.
            self.moveXY(x1, horse.pos.y)  
        elif x2 <= 79:
            # Move to the horse's y position but use x2 for the x position.
        distance = self.distanceTo(horse)
        if distance <= 10:
            # Move to the red x to return the horse to the farm.
            # Move back out into the pasture to begin looking for the next horse.

horse is a string, so it does not have a pos property.

I think you can use:

horse = self.findByType("horse", this.findFriends())[0];
1 Like

i did this and it still says: “property of x undefined.”

and now it says

Maybe remove the " " around the word horse