Is there a way to make it so that if the player receives damage that would be a killing blow, they are instead transported somewhere and healed? We are making a sort of dream world and are going to make the player die pretty much

But I don't want it to be an actual death, just leave the dream world type deal.
I would think OnDeath and OnDying would happen after the player is already dead, so not sure which functions to look into.