How do I outline certain blocks

I'm trying a flying platform that follows the player with

/execute @p ~ ~-1 ~ fill ~-1 ~ ~-1 ~1 ~ ~1 glass 0 replace air 

and then deleting the blocks with

/execute @p ~ ~ ~ fill ~-2 ~-2 ~-2 ~2 ~ ~2 air 0 outline glass 0

However, it destroys all the surrounding blocks. I would like to know if there's a way to make it so that it wouldn't destroy other blocks.


Solution 1:

That command doesn't exist in the form you're imagining it. There is a way to outline, but it doesn't make a rectangle in 2D and it isn't applicable to only certain blocks. You're thinking about two different syntaxes for /fill, but they can't be mixed. When in doubt, always look at the wiki, it tells you everything you need.

In your case, you should just put the command that replaces the glass with air first, then make the new platform immediately.