Is there a way to kill all players not in a minecart in Minecraft?
I am building a musical chairs Minecraft map, and I was wondering if there is a way to kill all players who aren't riding in a minecart?
Solution 1:
The tag you're looking for is RootVehicle
:
/kill @a[nbt=!{RootVehicle:{Entity:{id:"minecraft:minecart"}}}]
Solution 2:
The closest thing I can think of is setting up your minecarts like this (with the rails):
Then enter /execute positioned as @a if block ~ ~-1 ~ grass_block run kill @p
Replace grass_block
with your floor material (assuming that the material under the minecarts are the same).
When a player is in a minecart, the block under them will be the rail instead of the floor block (in this case, grass_block
). Those who are standing on the floor (the block under them is the floor block) will be killed.
However, there is only one problem. Players can survive by jumping. One solution is to make the whole room 2 blocks high, or to put barrier blocks above the players' heads.