Minecraft – How to break blocks with command blocks

minecraft-commandsminecraft-java-edition

I am familiar with the /setblock command, but I'm having trouble whenever I try to replace a block with air. The chat reads in red text, "Cannot place blocks outside of world", though I'm putting in the right coordinates. I can't seem to figure it out, can you help me? Command:

/setblock ~-147 ~74 ~-150 minecraft:air destroy

Best Answer

Look at your command:

/setblock ~-147 ~74 ~-150 minecraft:air destroy

Notice that you have a ~ before every coordinate, meaning that you will replace a block relative to your position, and being 74 blocks above you, it might be outside the world.
If you want to destroy a block at (-147,74,-150) you should remove the ~ like so:

/setblock -147 74 -150 minecraft:air 0 destroy

As user3878893 pointed out, you also need to include a data value for the block to be placed. For regular blocks just use a 0 (as above).