My camera is not following the player after spawn

Hi.
I got a problem with my Camera.
I have a main menu where I can choose one player among two of them. When I select a player it spawns the player in the game but as soon as the player spawns in the game and starts moving
The camera doesn’t follow the player it stays in the same position. Can someone help me?
This is my camera script.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Camera_Script: MonoBehaviour
{

private Transform player;

private Vector3 temPos;
[SerializeField]

private float minX, maxX;
// Start is called before the first frame update
void Start()
{
    player = GameObject.FindWithTag("Player").transform;
}

// Update is called once per frame
void LateUpdate()
{
    if (!player)
        return;

    temPos = transform.position;
    temPos.x = player.position.x;

    if (temPos.x < minX)
    {
        temPos.x = minX;
    }
    if (temPos.x > maxX)
    {
        temPos.x = maxX;

    }

    transform.position = temPos;

    
}

}

It’s following the transform the player starts in because you made player = to the player transform at start. It doesn’t track it, it keeps the one transform and tracks it. To change it, you can make it check for the gameObject player and have the camera follow “player.transform.position.x” in the follow code. I suck at explaining, maybe somebody can do it better

void Start()
{
player = GameObject.FindWithTag(“Player”).transform;
}
Untested, but try putting that in the Update() function. After that, LateUpdate() will behave accordingly.