Minecraft – How to test if score A is larger than Score B (different scoreboard objectives)

minecraft-commandsminecraft-java-edition

I am working on a LVL requirement system, and to do that I need to be able to compare 2 scoreboard objectives. I have been playing around with some ideas and I am still unsure on how to do it. If you can help me that would be great!

So basically I am trying to test if a player is holding an item with custom NBT that sets a higher level (achieved through a scoreboard command) than the players set LVL (again a scoreboard). I have tried /scoreboard players operation @p[Score_Tested_min=1] LVL1 -= @p[Score_Tested_min=1] lvl1 Obviously it would be hard to explain the complicated setup I have. But basically LVL1 and lvl1 are based on other objectives and the tested thing is a selector so it only works on one player per a tick.

Best Answer

So basically, you have a command that makes 2 scores identical and a score you want to subtract:

/scoreboard players operations (player1) (objectiveA) = (player2) (objectiveB)

(note player one and player two don't have to be different)

Next you would want a command that you subtract from (objectiveB):

/scoreboard player operations (player2) (ObjectiveB) -= (player2) (objectiveC)

Then you have a player selector in the next command. For instance:

/effect @p[score_Output_min=1] minecraft:slowness (time) (amplifier)

and that will show it is working right if you do the same general outline of what I did. Hope this helps. Just heads up this gets complicated real quick and it took me forever to figure out what i did wrong. I hope this helps you understand and recreate the idea if you need it.