Is it possible to use scoreboards from NBT number values?



  • 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.



  • 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  run data get entity  
    scoreboard players operation   -= $Price 
    

    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.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2