[Java Edition 1.15.2] I have a pressure plate that activates two command blocks in the nether:
execute as @p in minecraft:overworld run tp @p 98 67 101 180 0
which teleports the player from the pressure plate in the nether to a specific location in the overworld facing north.tellraw @a {"text":"","color":"green","bold":true,"extra":[{"selector":"@p"},{"text":" has teleported to the overworld!"}]}
which tells the chat who teleported and to where.
I have the same thing in the overworld going to the nether. This works perfectly fine when going from the overworld to the nether, however, when going from the nether to the overworld the tellraw command block targets my friend in the overworld with @p instead of me.
For example, say I am playerOne and my friend is playerTwo. When I am going from the overworld to the nether is says playerOne has teleported to the nether!
which is what is supposed to happen. But, when teleporting from the nether to the overworld, I see playerTwo has teleported to the overworld!
which is incorrect.
How can I get this to work so that it is always the nearest player no matter what the dimension? If it makes a difference, playerTwo is always in the overworld while this is happening.