3

I'm making a Minecraft map, and I want to run a commandif your score is below a certain number. However, the less than < comparison doesn't seem to work.
How can I get this to work?

My current command is:

execute if score <player> mana < 200 mana run setblock 6582 74 -266 minecraft:air

For more information, I'm making a "mana" system where I have a hopper clock adding 1 mana each. When a certain player reaches 200 mana, a command sets a redstone block to stop the hopper clock.
It's all working fine, but the command to remove that block when there is less than 200 mana (to generate more via the hopper clock) doesn't seem to work.

I'm playing on Minecraft 1.16.

0

1 Answer 1

6

The operators <, <=, =, >=, and > are used to compare your score with another player's score.

execute if score Alice Kills > Bob Kills run tellraw @a {"text":"Alice is winning!"}

In your command, 200 is actually a player name:

execute
  if score XX mana < 200 mana           # If XX's `mana` score is less than `200`'s `mana` score...
run setblock 6582 74 -266 minecraft:air # then set a block.

To test for a certain number, use the matches keyword:

execute
  if score XX mana matches ..200        # If XX's `mana` score is equal to or less than 200...
run setblock 6582 74 -266 minecraft:air # then set a block.

Instead of using comparison operators, use ranges to specify allowed values.

  • 0: exactly 0
  • ..0: equal to or less than 0
  • 0..: equal to or greater than 0
  • 0..1: between 0 and 1 inclusive
  • 0.1..1.5: between 0.1 and 1.5 inclusive
  • ...1: equal to or less than .1. (.1 == 0.1)
  • 1...: equal to or greater than 1. (1. == 1.0)

This answer is applicable to all Minecraft versions 1.13 and newer.

1
  • Thanks, man, really saved me there :) Jul 30, 2020 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .