Minecraft /execute as a player if they are alive

Minecraft /execute as a player if they are alive - Person in White Nike Soccer Shoes Standing on Black Floor

I have an /execute command in a repeating command block, such as:

execute @a ~ ~ ~ say hi

This makes every player say hi every tick, even if they are dead and at the 'Respawn?' screen.
How would I make the /execute only happen if the player is alive?



Best Answer

You can use a selector that does not have the ability to target dead players, such as @e (with type=Player to ensure player-based targeting):

/execute @e[type=Player] ~ ~ ~ say hi



Pictures about "Minecraft /execute as a player if they are alive"

Minecraft /execute as a player if they are alive - Free stock photo of athlete, fitness, long tennis
Minecraft /execute as a player if they are alive - Free stock photo of activity, athlete, boy
Minecraft /execute as a player if they are alive - Man in White Jersey Shirt and Pants Playing Baseball



How do you execute a command as someone else in Minecraft?

Type the command in the chat window and press the Enter key to run the command. Once the cheat has been entered, the flame particle will appear directly 1 block in front of the entity running the command.



How to detect if a player is at a certain place! Java 1.16.1 COMMANDS IN DESCRIPTION




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: cottonbro, ramiz haider, Kindel Media, Mark Milbert