I get 'Failed to execute 'detect' when running my Minecraft command?

/execute @a ~ ~ ~ detect ~ ~ ~ minecraft:stone_button 0 /scoreboard players >set @a slow 2
For some reason this just wont work. It comes up with:
[18:08:39] Failed to execute 'detect' as mr_assley19
I am trying to test for a button - if the button is found it sets the score to 2.
I was also wondering if you can test for a block in radios of 1
Best Answer
Basic troubleshooting
First of all, let's talk about your command here
/execute @a ~ ~ ~ detect ~ ~ ~ minecraft:stone_button 0 /scoreboard players >set @a slow 2
Everything up to the 0 is fine, but not very useful (see below). The command fails because the syntax for the scoreboard
part is wrong. First of all, the >
is a syntax error.
Secondly, make sure that the scoreboard objective called slow
actually exists by executing
/scoreboard objectives add slow dummy
What it does might not be what you want
Now, regarding what this command does when it works, and why else it might fail:
It will look for a stone button with data value 0, i.e. one facing downwards, at the position of the feet of every player on the server. While the command itself would work, detecting this is highly unlikely since it involves someones head being inside a block (the bottom of which the button is one), or a floating button. What you are likely looking for data value -1, which allows all orientations of the button (If not, check the linked wiki page for the correct orientation, or change the coordinates at which you are trying to detect.)
Furthermore, if you use @a
for the scoreboard part
, you will set everyone's slow
score to 2, not just that of the person at the button. Use @p
to only affect the player closest to the coordinates specified in execute
, which is exactly at the position of the player. If you want to change the position where the button has to be (i.e. to the head of the player), change the second set of coordinates.
Fixed command, looking for any stone button at any player's heads:
/execute @a ~ ~ ~ detect ~ ~1 ~ minecraft:stone_button -1 scoreboard players set @p slow 2
Pictures about "I get 'Failed to execute 'detect' when running my Minecraft command?"



Why do commands not work in Minecraft?
You can not run game commands in Minecraft until you have turned on cheats. Game commands let you switch between Creative and Survival game modes, change the time of day, change the weather, or summon a mob.Why is my command block in Minecraft not working?
You may find that the commands you are trying to have the command block execute are not working. This may be due to the certain limitations the block has on what commands it can run successfully. Command Blocks will execute commands with an OP level 2 permissions.How do you use the execute command in Minecraft?
Type the command in the chat window and press the Enter key to run the command. Once the cheat has been entered, the flame particle will appear directly 1 block in front of the entity running the command.How do you use the Testfor command in Minecraft?
How to Enter the CommandTubthumping (I Get Knocked Down) Lyrics
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Kampus Production, Kampus Production, Kampus Production, Yaroslav Shuraev