GameManager class error

Hi, im working with a game manager who gets a player transform and a player prefab, i can assign these variables in the inspector directly, i worked with it in one scene and it work perfectly, but i tried to use in another scene and i have an Unassigned Reference Exception it says my variable PlayerSpawnPoint has not been assigned and probably need to assign in the inspector, but i don´t know why, because in the inspector te transform is assigned.

Here is the code of my class:

    public Transform playerSpawnPoint;
    public GameObject player;
    public static GameManager instance { get; private set; }

    private void Awake()
    {
        if (instance == null)
            instance = this;
    }

    // Start is called before the first frame update
    void Start()
    {
        instance = this;
        player = GameObject.FindGameObjectWithTag("Player");
        player.transform.position  = playerSpawnPoint.position;
    }

You should check if an instance of the GameManager is already loaded, just add

else
    Destroy(gameObject);

to the Awake method.

also you don’t need to do it again in the Start method.

Maybe that’s where you issue comes from ?

Your “PlayerSpawnPoint” is a reference to a scene object, so when you change scenes, that object is gone, and the variable becomes null. You’ll need to get a reference to the spawn point in the next scene.

Actually I already solved it, the problem was that I had assigned my game manager to another object and Unity didn’t know which game manager prefers, but thanks for the reply and the time to read