Minecraft – Command block won’t execute trigger commands

minecraft-commandsminecraft-java-edition

I'm attempting to create an interface that allows players without permissions to activate commands by changing their own scoreboard value, however in order for this to work i need to reset their scoreboard number after the command has executed so the command doesn't repeat.

the player can use the command
/trigger test set 1
and a command block will execute a command at the player's position
However after the command has been activated i'm trying to reset the players scoreboard to zero with a command block running execute at @a trigger test set 0 which doesn't seem to do anything

Can anyone tell me what I am doing wrong?

P.S I already have a repeat command block running scoreboard players enable @a test the issue command block just doesn't seem to be doing anything

Best Answer

To reset the players score to 0 you will need to use as instead of at, to execute the trigger command AS the player, not at the player's location. You also forgot about the run literal. Here's the correct command:

execute as @a run trigger triggertest set 0

In your case you can also simply use the scoreboard command like this:

scoreboard players set @a triggertest 0

Or even like this, because you keep enabling it anyway, so it won't be removed from the scoreboard for longer than one tick:

scoreboard players reset @a