Minecraft – How to make a player die when they step off a certain block

minecraft-commandsminecraft-java-edition

I keep finding things for when people step on a block, but I need for when they step off a block.

I'm trying to make a command set on 1.16 where if a player were to no longer step on 1 of 2 specified blocks (example: stone and cobblestone) they will die.

A friend asked me to make this for them since they are trying to do a survival challenge in Minecraft where they are only allowed to be on specific blocks, claiming this will help reinforce the rules. If makin it 2 blocks is not possible then that's alright.

Commands that start off with /execute @p ~~~ detect ~~~ seem to return errors each time I try to run them. In fact, any commands that have ~~~ detect~~~ always fail no matter what I put.

Best Answer

In order to do this use the following

/execute@e[type=player] ~~~ detect ~~~ minecraft:stone 0 kill@e[type=player]

the detect will see if a(n) entity steps on a certain block. IF the entity is on that block then the command will execute. Any other block you want them to die on then set up a chain command block