Can't move my player to a specific location

So I’m making a game where when the player clicks on a certain object they should be moved to a location. When looking online it seems that I’m doing exactly what everyone else is doing. In game it registers that the item is clicked and glitches for a second as if it will move to the location, but then the player is exactly where they were before.

{

//Identify the player
public GameObject Player;
private Transform DeskSitLocation;
private Transform PlayerTransform;
// Start is called before the first frame update
void Start()
{
    DeskSitLocation = GetComponentInChildren<playerStandLocation>().transform;
    PlayerTransform = Player.GetComponent<Transform>();
}

private void OnMouseDown()
{
    Debug.Log("Helloo");
    PlayerTransform = DeskSitLocation;
}

}

it also doesn’t work when I use .position

I think you can’t replace the Player’s transform by another transform, you must code this:

 //Identify the player
 public GameObject Player;
 private Transform DeskSitLocation;
 private Transform PlayerTransform;
 // Start is called before the first frame update
 void Start()
 {
     DeskSitLocation = GetComponentInChildren<playerStandLocation>().transform;
     PlayerTransform = Player.GetComponent<Transform>();
 }
 private void OnMouseDown()
 {
     Debug.Log("Helloo");
     PlayerTransform.position = DeskSitLocation.position;
     //PlayerTransform.rotation= DeskSitLocation.rotation; //use this only if you want the same rotation in the player and the object clicked
 }

I hope this can helps you :smiley:

It didn’t work because my character controller was still enabled, once I disabled it when clicked, it worked