1

I have this NBT tag on a slimeball: {price:200}.

How would I use /scoreboard players remove or something similar to that to remove coins from a player off of this value price?

So in this case it would remove 200 coins from me, but if I changed this number to something like 1000, it should remove 1000 coins from me.

0
1

You can use the execute store to store the price into a fake's player score and then use the scoreboard operation to remove that quantity.

execute store result score $Price <score name> run data get entity <slime target> <nbt path>
scoreboard players operation <player target> <score name> -= $Price <score name>

Where slime target is a player with the item or the item on ground itself.

A fake player is just a username that can't be registered using special chars like $ or #. This way we make sure our system will never use a real player name and it makes it more readable.

1
  • Oh! Thanks for this! I completely forgot the operation subcommand existed. Thank you so much! Dec 12 '21 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.