Say death position

Hi, I try to make a datapack that print the X Y Z when a person dies. It didn't work at all, I surely forgot something. I'm in 1.21.6 pre2

Here is my structure:

  • datapacks
    • death_coordinates
      • pack.mcmeta
      • data
        • minecraft/tags/functions/tick.json
        • death_coordinates/functions/log_death.mcfunction

tick.json:

{
  "values": [
    "death_coordinates:log_death"
  ]
}

log_death.mcfunction:

# Check if the player is dead (health is 0 or less)
execute if entity @s[scores={health=..0}] run tellraw @a {"text":"[Death Coords] ","color":"dark_red","extra":[{"selector":"@s","color":"gold"},{"text":" died at X: ","color":"gray"},{"score":{"name":"@s","objective":"x_coord"},"color":"aqua"},{"text":", Y: ","color":"gray"},{"score":{"name":"@s","objective":"y_coord"},"color":"aqua"},{"text":", Z: ","color":"gray"},{"score":{"name":"@s","objective":"z_coord"},"color":"aqua"}]}

# Store player coordinates into scoreboard objectives
execute store result score @s x_coord run data get entity @s Pos[0] 1
execute store result score @s y_coord run data get entity @s Pos[1] 1
execute store result score @s z_coord run data get entity @s Pos[2] 1

pack.mcmeta:

{
  "pack": {
    "pack_format": 79,
    "description": "Affiche les coordonnées de mort des joueurs"
  }
}

I also create manualy :

/scoreboard objectives add health health
/scoreboard objectives add x_coord dummy "Death X"
/scoreboard objectives add y_coord dummy "Death Y"
/scoreboard objectives add z_coord dummy "Death Z"

And when I died I want to know where I died but nothing happend.

Continue to help post