1

I'm trying to make a game in Minecraft 1.16.5, and it has a shop. But since I am forced to use the /execute command I don't know how to make it so when you have 25 or more points, it subtracts 25 and unlocks it. Everything I found was from years ago, so they are out of date.

3
3

From the Minecraft Wiki:
"@e[scores={myscore=5..}] — Select all entities with a score in objective myscore of five or greater."
In your situation you will need at least two command blocks where the first will be a repeating command block detecting the entities with score higher or equal to 25 and removing the required points:

execute as @e[scores={scoreboard=25..}] run scoreboard players remove @s scoreboard 25

And the other command block has to be a conditional chain command block (has to be conditional so it only executes if the first one is executed successfully) and it is going to unlock the thing.
If you need to do some actions on the player that reached the score you will most likely need more command blocks and will need to use the target selector in each of the command blocks and remove the required score after all the commands targeting the player are done. Alternatively you could use another scoreboard or a team to identify the player.

1

You would use .. for min/max. For example, the following command will test for a score of 25 or more.
/execute if entity @p[scores={custom=25..}]
..25 would be 25 or less, and 1..25 would be 1 to 25.
To subtract 25 from the score, you would use remove.
/execute as @a[scores={custom=25..}] run scoreboard players remove @s custom 25

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.