Minecraft – How to detect if a player is standing on a certain colour wool

minecraft-commandsminecraft-java-edition

I'm making a map for Minecraft and I want the player to teleport when standing on orange wool. I used this:

/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:wool 1 0 tp @p[c=1] 0 0 0

But I constantly get an error

[16:40:51] Failed to execute 'detect' as F1NN3RT

(F1NN3RT is my in-game name)

What am I doing wrong?

Best Answer

The syntax of execute detect is:

/execute <entity> <x> <y> <z> detect <x> <y> <z> <block> <dataValue> <command>

You have got an extra 0 after the dataValue, which Minecraft thinks is meant to be the command. Try:

/execute @a ~ ~ ~ detect ~ ~-1 ~ minecraft:wool 1 tp @a[c=1] 0 0 0

I've also switched the @p for an @a[c=1]. This is because @a will select dead/alive players, but @p will not. If a player were to die on orange wool with the original command, they would keep teleporting the nearest alive player to those coordinates.