Can I /execute a command at players with a certain score?

Can I /execute a command at players with a certain score? - Aerial View of Soccer Field

For a project I'm working on, I want to be able to execute a setblock command at a player with a certain score. I've tried doing

/execute @a[score_xp_min=100] -insert command here-

but all it says is that I've provided an improper UUID format. Is there any way to /execute commands at players with certain scores?



Best Answer

The selector format is correct, but the problem is that the syntax of /execute is:

/execute <Target> <X> <Y> <Z> <Command>

To fix your problem simply add 3 tilde (~) after the @a selector:

/execute @a[score_xp_min=100] ~ ~ ~ <Command>



Pictures about "Can I /execute a command at players with a certain score?"

Can I /execute a command at players with a certain score? - Football Players
Can I /execute a command at players with a certain score? - Gathering Football Players
Can I /execute a command at players with a certain score? - Ice Hockey Players



How do you use the execute if score command?

By default, server ops have access to all commands, including commands like /stop . You can change this by modifying the op-permission-level in your server. properties file. Setting it to 4 (which is the default) allows ops to use all commands.

How do you allow players to use certain commands in Minecraft?

If you only want it to run the command the first time they join, try this:
  • Run this in the chat: /scoreboard objectives add joined dummy.
  • In command blocks on a fill clock: /scoreboard players add @a joined 0 /execute @a[score_joined=0] ~ ~ ~ [command you want to run]




  • /execute if score // Minecraft 1.19 Command Tutorial




    More answers regarding can I /execute a command at players with a certain score?

    Answer 2

    That's easy, just run this command once:

    scoreboard objectives add test dummy "test"
    

    Then have a repeating command block with this command:

    execute as @a at @s if score @s test = @s 3.. run [enter command here]
    

    You can change the 3.. to whatever number you want to test for, for example 5..

    You can add, set, and reset the points with these commands:

    scoreboard players add [player] test [amount]
    scoreboard players set [player] test [amount]
    scoreboard players reset [player] test
    

    And for all the above commands, you can change the word test to whichever objective name you'd like to use.

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Mike, Joe Calomeni, Pixabay, Pixabay