Is it possible to remove a scoreboard score by a scoreboard score?

The question I'm asking might be confusing but I'll give an example:

/scoreboard players remove @p score score

So it possible to do something like this?


Solution 1:

remove, add, and set will only accept constants. To take away one score from another, use operation.

For example, the following will reduce the closest player's score1 by their score2:

/scoreboard players operation @p score1 -= @p score2

The syntax is:

/scoreboard players operation <targetName> <targetObjective> <operation> <selector> <objective>

The available operations are, from the wiki:

  • += Addition: add selector's score to targetName's
  • -= Subtraction: subtract selector's score from targetName's
  • *= Multiplication: set targetName's score to the product of targetName and selector's scores
  • /= Integer Division: set targetName's score to itself divided by selector's score
  • %= Modular Division: set targetName's score to the remainder of the division between itself and selector's score
  • = Assign: set targetName's score to selector's score
  • < Min: if selector's score is less than targetName's score, then set targetName's score to selector's score
  • > Max: if selector's score is greater than targetName's score, then set targetName's score to selector's score
  • >< Swaps the scores of selector with targetName

All but >< (swapping) will only affect the targetName's targetObjective. selector's objective will be left as it is.