Thunderhooves, I need help

yak.pos.y > hero.pos.y;
should be
if(yak.pos.y > hero.pos.y) {

I tried it too, look

As of your latest screenshot, you have an else if that isn’t attached to an if.
It should be more like:

if(yak) {
    if( yak position is greater than hero position ) {
        // build a fence 10 units down
    } else if( yak position is less than hero position ) {
        // build a fence 10 units up
    }
} else {
    // the code you already have here works
}

why did you repeat the same if two times? if(yak.pos.y > hero.pos.y) {
if( yak position is greater than hero position ) {

My bad, was trying to type it quickly. Edited

Based on the code you have in the screenshot, you could just change
yak.pos.y > hero.pos.y
to
yak && yak.pos.y > hero.pos.y

and change

yak.pos.y < hero.pos.y
to
yak && yak.pos.y < hero.pos.y

Basically, you don’t know if a yak even exists yet, so you need to check for it before you can read its position.

ohhhh I put the x + 10 (nevermind)

You have an extra curly brace on line 9 in the screenshot above. You don’t need to do the yak && thing if you choose to surround your code with if(yak) { }

tanks I got it correct :smiley: