putting an object's x coordinate to another object

Hello:
I want to know if I can get the x coordinate of an object and put it in another object.
I need this because I want to put the camera aligned to the player.
Thank you very much!!!

Yes, you can.

In all seriousness…you have to first get a reference to the Object, possibly via a variable of type GameObject exposed in the Inspector, or by using GameObject.FindWithTag(“Player”) in the Start function, and then you can access its transform, just like you can access the transform of the object the script is attached to.

Example:

private GameObject player;

void Start() {
    player = GameObject.FindWithTag("Player");
}

void Update() {
    transform.position = player.transform.position;
}

Have a look here for an overview on how to access other GameObjects.