Minecraft – Is It Possible To Pass The Selected Player Down The Command Block Chain

minecraft-commandsminecraft-java-edition

If I have an impulse block connected to chain command block I can trigger the two commands by pressing a button or standing on a pressure plate (or other redstone).

e.g. give a status effect then teleport

effect give @p minecraft:instant_health 1 10
teleport @p 10 75 10 90 0

However, this is using two selectors (one for each command block).

Is it possible to pass the selected player as an identifier from the first block to the second block?

EDIT: I am playing Java 1.15.2.
I'd be separately interested to know if it is possible on one version and not on another.

Best Answer

Not directly but you can tag the player and then use that tag as criteria for the other command blocks. Example:

/tag @p add someTag

and then your other command blocks would use that tag like this:

/effect give @a[tag=someTag] ...