Script, teleporting a object tagged with "player" to object

Hi I have a scene with 2 cameras and one camera is the game, second is the map. when u click on a planet
on the map I want to teleport the player to a invisible cube at that planet.

var destination : Transform;
 
//when click teleport to planet
  if (Input.GetMouseButtonDown(0)){
    var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    var hit: RaycastHit;
    if (Physics.Raycast(ray, hit)){
   
   // Hyperjump player to selected planet
    GameObject.FindGameObjectsWithTag ("Player");
      {
        ("Player").transform.position = destination.position;
    }
}

GameObject.FindGameObjectWithTag(“Player”) is actually returning a value. You need to store that in something (much like you are doing with ScreenPointToRay). Then you can do your move operations on that object. Currently

("Player").transform.position = destination.position;

Isn’t doing what you want it to do. It also looks like you have mismatched braces, but I’m not certain about that. Try something like the following:

    var destination : Transform;
    var player : GameObject;

    //when click teleport to planet
    if (Input.GetMouseButtonDown(0)){
      var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
      var hit: RaycastHit;
      if (Physics.Raycast(ray, hit)){
        // Hyperjump player to selected planet
        player = (GameObject)GameObject.FindGameObjectWithTag ("Player");
        player.transform.position = destination.position;
      }
    }

I added the ‘player’ variable, which gets set by GameObject.FindGameObjectWithTag
I also changed the formatting a little bit to make it easier for me to read.

You need to assign the player to a variable

var player : GameObject;
player = GameObject.FindGameObjectsWithTag ("Player");
player.transform.position = destination.position;