Sarven gaps help!

It keeps going back into the wall can anyone help?

x = hero.pos.x
y = hero.pos.y
y = y - 10

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # buildXY a "fence" 20 meters to enemy's left.
        hero.buildXY("fence", enemy.pos.x - 20, enemy.pos.y)
        # moveXY down 10 meters.
        hero.moveXY(x, y)
        pass`Preformatted text`

(and im kinda new so im still figuring stuff out on this discourse)

Welcome‌ ‌welcome‌ ‌to‌ ‌the‌ ‌forum!‌ ‌It‌ ‌is‌ ‌a‌ ‌lovely‌ ‌place‌ ‌where‌ ‌you‌ ‌can‌ ‌share‌ ‌all‌ ‌kinds‌ ‌of‌ stuff‌ ‌(appropriate‌ ‌of‌ ‌course),‌ ‌share‌ ‌bugs,‌ ‌and‌ ‌even‌ ‌get‌ ‌assistance‌ ‌for‌ ‌code!‌ ‌We‌ ‌suggest‌ ‌that‌ ‌you‌ ‌review‌ ‌this‌‌ topic‌ ‌which‌ ‌shows‌ ‌all‌ ‌essentials‌ ‌of‌ ‌this‌ ‌board!‌ ‌And‌ ‌we‌ ‌suggest‌ ‌you‌ ‌review‌ this topic‌ ‌which‌ ‌shows‌ ‌how‌ ‌to‌ ‌post‌ ‌your‌ ‌code‌ ‌correctly!‌ ‌Thanks!!‌ ‌ :partying_face: :partying_face:
Could you format your code correctly and can you send a link to the level?


I used just coordinates for building the fence

You can’t use variables that you’ve defined outside the while loop. They will stay as two constant values like 24 and 30. You need to use values which will change with your movements. hero.pos.x and hero.pos.y. Note that you also need to move down 10 meters, so you’ll need to subtract 10 off hero.pos.y.

ok thankyou ill try that