How do I create an object that teleports the player to themselves when they appear on the scene?

Godot Version

Replace this line with your Godot version
4.2.2

Question

Ask your question here! Try to give as many details as possible
I am making a location that will have several entrances. And each entrance should move the player to a different place in that location. Previously, a script was used for this that was written for me by another member of this forum (and I am very grateful to him). But for some reason, this system broke. No matter how I changed the coordinates to which the player needed to be transferred, he always appeared at the coordinates set for the first time. And I came up with the idea to make an object to which the player would be teleported when moving to the stage. And so that there could be several such objects on one stage. Whether this is a property of the object itself, or the teleportation itself will be carried out by the scene script, and the object will only indicate the desired point, it does not matter. Please help…

Well you need to access the player in the ready-method, for example by using groups

func _ready():
    var player = get_tree().get_nodes_in_group("Player")[0]
    player.global_position = global_position

make sure to put the player in the “Player” group