How do I break blocks with command blocks?

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).
Pictures about "How do I break blocks with command blocks?"



Can you break command blocks in creative?
But it feels strange that only op'd players in creative can program command blocks, but players in survival can break them easily. They should have the resistance of obsidian, or at least of stone, to prevent players breaking complex redstone structures.How do you use the break command in Minecraft?
Minecraft: Using the fill command to clear chunks To do this, players can either use the F3 key on Minecraft: Java Edition or the "show coordinates" option in Bedrock Edition to note the start and end points of where they want the fill command to clear.What is the command to clear chunks in Minecraft?
Breaking is accomplished by holding down the destroy button while the cursor is over a block. If the player is within range of the target, the player's hand begins swinging, making a repetitive "thump" noise as the player hits the block, and cracks appear.HOW TO USE COMMANDS TO MASS FILL/DESTROY/REPLACE BLOCKS in Minecraft Bedrock (MCPE/Xbox/PS4/PC)
More answers regarding how do I break blocks with command blocks?
Answer 2
You can try
/setblock -147 74 -150 minecraft:air 0 destroy
Or
/fill -174 74 -150 -174 74 -150 air
Answer 3
The reason it says "Cannot place blocks outside of the world" is because the place where it wants to remove the block with air is outside the loaded area.
If you're on java then what is considered not "outside of the world" is anything inside an 8 chunk perimeter
If you're on bedrock then you can set the perimeter as a slider when editing the world the slider says simulation distance and you can set it higher the stronger your device is, it starts at 4 then 6 then 8 chunks is the max (though i might be wrong)
Answer 4
Hey guys i found and easy way of placing and destroying a block. The command is
/setblock <x> <y> <z> (type of block) 0 destroy
It doesn't matter if you put the / in the front of the command it works either way.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Tatiana Syrikova, Tatiana Syrikova, Cup of Couple, Yan Krukov