On Player Respawn
Introduction 
Sourced by the Bedrock Commands Community (BCC) Discord
This system will run your desired commands on the event that a player respawns from death state.
Setup 
To be typed in Chat:
/scoreboard objectives add wiki:respawn dummy
If you are working with functions and prefer to have the objective added automatically on world initialisation, follow the process outlined in On First World Load.
System 
## Your Commands Here (Example)
execute as @e[scores={wiki:respawn=1}] run say I died and respawned.
## Set Player States
### Currently respawning
scoreboard players set @a wiki:respawn 1
### Currently not respawning
scoreboard players set @e[type=player] wiki:respawn 0
Here, we have used an /execute - say command as an example, but you can use any command you prefer and as many as you need.
Just make sure to follow the given order and properly apply the @e[scores={wiki:respawn=1}] selector argument as shown for your desired commands.
Explanation 
wiki:respawn=0player is alive or had already respawned.wiki:respawn=1player is dead or has just respawned (in the current game-tick).@aselector will target all players alive/dead. Hence, we will use it to mark players as1'respawning'@eselector on the other hand will only target players who are alive, so we can use this to mark all alive players 0 'respawned'
Now that respawning players are 1 and respawned players are 0, we can use this knowledge to run our desired commands when the players with score 1 respawn from death state. They are targeted with @e selector.
In the system, your desired commands must come before the other 2 commands because players change from death state to alive state along the start of the game-tick, before commands are run.
Hence, if we were to put them at the end, the other 2 commands would set respawning players score to 0 first and the commands you want to run won't be able to select those players as our selector argument is @e[scores={wiki:respawn=1}], not 0. Using 0 would not work as then it would repeat endlessly even on players who have already respawned.
Tick JSON 
If you are using functions instead of command blocks, the on_respawn function must be added to the tick.json in order to loop and run it continuously. Multiple files can be added to the tick.json by placing a comma after each string. Refer to Functions documentation for further info.
{
  "values": [
    "wiki/event/players/on_respawn"
  ]
}If using functions, your pack folder structure will be as follows:
- 📝on_respawn.mcfunction
 
- 📝tick.json
 
- 🖼️pack_icon.png
 - 📝manifest.json
 

