Why won't this execute command work?



  • I'm trying to make a datapack and in it you cannot sleep unless you are y 100 or above, but my command doesn't work. Can anyone explain why P.S: playerheight is a scoreboard that updates according to the Y coordinate.

    execute at @e[tag=avian,scores={slep=1..}] if score @p[tag=avian]  
    playerheight < 100 run run setblock ~ ~ ~ air destroy
    


  • There are multiple things, that might be wrong:

    Your sleeping scoreboard is misspelled slep, which might cause issues, unless you've have the same misspelling everywhere.

    You're using <. This compares the score of two players/entities in two scoreboards. Your code would compare the score of @p[tag=avian] in playerheight with the score of 100 in run. What you want is matches: if score @p[tag=avian] playerheight matches ..100.

    Also note two things:

    You can check multiple scores at once: execute at @e[tag=avian,scores={sleep=1..,playerheight=..100}]

    And for the height of a player you don't even need a scoreboard: execute at @e[tag=avian,scores={sleep=1..},y=100,dy=-200]




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2