How to teleport a player to his death location

When a player dies they respawn in their spawnpoint, but I made a way to teleport them when death is detected (though a minecraft:die scoreboard) and using storages to get their deathX Y Z and it works fine, but only if the player dies when using /kill. If they die from fall or other thing it works and stores the coords fine but it dosents tp the player? why can this be?
Continue to help post