Imagine I have a gold ingot with the NBT tag of {price:100}, and I have a scoreboard named "Money". How am I able to subtract the value of the player's Money by the number price in the NBT?

This is in Minecraft Java Edition 1.17.1.

  • Where is the item? On ground, or inside the player inventory?
    – BunnyMerz
    Nov 6, 2021 at 18:15
  • its in the inventory yes Nov 6, 2021 at 18:32
  • Ah... this is a problem. I'm not sure how to target a item inside the player's inventory as you have to specify the Nbt Path. Usually it is a good idea to show how the other parts of your idea works. When should you subtract the price from the player? when he picks up the item? what happens after it, does the item lose the {price:??} nbt?
    – BunnyMerz
    Nov 6, 2021 at 18:36
  • Its in the player's mainhand. So under the player it would be SelectedItem. Nov 6, 2021 at 18:37
  • And also, the item doesnt lose the price nbt tag. I'm going to clear it off the player after the money has been subtracted from. Nov 6, 2021 at 18:40

1 Answer 1


I found it out:

I made a dummy scoreboard called prices

I ran /execute store result score #price prices run data ...

and so on with the data.

Then I did /scoreboard players operation @s money -= #price price

and it subtracted just fine!

You must log in to answer this question.

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