Minecraft code inaccuracy [closed]

I put in this command and it didn't work:

/execute @a ~ ~ ~ detect ~ ~-1 ~ emerald_block 0 tp @s 30 30 30

How can I make the code work?


Solution 1:

This would be the correct way:

/execute @a ~ ~ ~ detect ~ ~-1 ~ emerald_block 0 tp @s 30 30 30

You can put this in a repeating command block. I don't know why it didn't work for you, but it works fine when I try it. Maybe you didn't put it in a repeating command block that has Redstone as always active.

I just assumed you used bedrock edition because of the syntax but if you're using java edition this is the correct command:

/execute as @a at @s if block ~ ~-1 ~ minecraft:emerald_block run tp @s 30 30 30