#How to teleport a player to his death location

1 messages · Page 1 of 1 (latest)

leaden belfry
#

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?

sonic hatchBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1745443648:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

humble crescent
#

there is very little code in this pack

#

It's probably faster if you take a look

leaden belfry
#

i send a tellraw with a click event to tp and that works

#

what dosents work is using the function the same tick the player dies

humble crescent
#

because the player is dead

leaden belfry
#

but it does work when you die by /kill

humble crescent
#

idk if there are differences how that's handled

leaden belfry
#

i can fix it by running ts a tick after or smthng

leaden belfry
#

like ts

#

i want to tp @s ~ ~ ~ ~ ~

humble crescent
#

you can read the players Rotation nbt

leaden belfry
#

because else when you tp u will face a fixed way always

#

but does this store it?

humble crescent
#

don't rotate with teleportation, use the rotate command

leaden belfry
humble crescent
#

/rotate @s <pitch> <yaw>

leaden belfry
humble crescent
#

Rotation

leaden belfry
#

so I can do tp @s @n[type=,tag]

humble crescent
#

use macros

leaden belfry
humble crescent
#

the macros doesn't get more expensive if you add more variables

leaden belfry
#

i could summon an armor stand at the death coords with macros

#

and give this player a tag

#

and run repeat tp all players with a tag to the neares armor stand

humble crescent
#

if you really want to go this route, at least use a marker

leaden belfry
#

okay so a marker has rotation and stuff

leaden belfry
#

like I could do 2 or 3 functions with storages but idk if this is optimized

humble crescent
#

why do you want to tp them while they're dead (or in the respawn tick)?

humble crescent
leaden belfry
#

but if I have a few players that can die at any time

#

and I need to loop tp them to where they died

#

or if they die at the same time

#

is there any score that saves time since last death?

humble crescent
#

yes

#

time_since_last_death

leaden belfry
#

nice

leaden belfry
# humble crescent yes

yaw and pitch always get saved as 0 0 i guess because the function is run at the death tick?

humble crescent
#

just make it run 1 tick later

leaden belfry
humble crescent
#

you could periodically store that data

leaden belfry
#

specially since I need to use a dinamyc store

humble crescent
#

nbt manipluation is bad but not that bad

leaden belfry
#
$execute store result storage pdm:player main.$(id).gameData.deathanim.yaw int 1 run data get entity @s Rotation[0]
$execute store result storage pdm:player main.$(id).gameData.deathanim.pitch int 1 run data get entity @s Rotation[1]
#

so every tick i have to run

humble crescent
#

my health display datapack also uses dynamic, entity specific data stoprages. and it does much more nbt stuff than that. You don't even notice that.

leaden belfry
#

a function to get my id and another with macros to save my yaw and pitch

humble crescent
leaden belfry
#

is schedule good ?

#

like schefule functoon save 5t

humble crescent
#

a 3 or 4 tick delay won't be that noticeable

#

yes

leaden belfry
#

im on aternos server so optimization is important