FindObjectOfType not finding Player

I followed a tutorial of this man: Unity Create a Game Series (E23. Audio pt.2) - YouTube, but I got this error saying: “Assets/Scripts/AudioManager.cs(50,34): error CS0246: The type or namespace name `Player’ could not be found. Are you missing an assembly reference?”. I have tried creating an empty object with an audio listener and type Player, but that didn’t work. I’m new to Unity, so help is appreciated. This is the piece of code that’s troubling me:

void Awake()
{
    if (instance != null)
    {
        Destroy(gameObject);
    }
    else
    {

        instance = this;
        DontDestroyOnLoad(gameObject);

        library = GetComponent<SoundLibrary>();

        musicSources = new AudioSource[2];
        for (int i = 0; i < 2; i++)
        {
            GameObject newMusicSource = new GameObject("Music source " + (i + 1));
            musicSources *= newMusicSource.AddComponent<AudioSource>();*

newMusicSource.transform.parent = transform;
}
GameObject newSfx2Dsource = new GameObject(“2D sfx source”);
sfx2DSource = newSfx2Dsource.AddComponent();
newSfx2Dsource.transform.parent = transform;

audioListener = FindObjectOfType().transform;
if (FindObjectOfType() != null)
{
playerT = FindObjectOfType().transform;
}

masterVolumePercent = PlayerPrefs.GetFloat(“master vol”, 1);
sfxVolumePercent = PlayerPrefs.GetFloat(“sfx vol”, 1);
musicVolumePercent = PlayerPrefs.GetFloat(“music vol”, 1);
}
}

Your GameObject does not have the type “Player”, it has the type “GameObject”. The “Object” that FindObjectOfType refers to is Unity’s Object class, which is the base class for GameObjects, Components, and all the different types of assets (Texture2D, ScriptableObject, etc).

For the code snippet you posted to work, you would need to (for example) create a script named Player that defines a class named Player that extends MonoBehaviour, which you can then attach to your empty gameobject like a component. FindObjectOfType() will then get you a reference to that script (not the gameobject itself! Though the script will have a reference to both the gameobject and the gameobject’s transform).

EDIT: Additionally, you should save the result of that method in a variable or field so you only need to call it once instead of twice, e.g. Player playerRef = FindObjectOfType<Player>(). You also shouldn’t be using FindObjectOfType if you can avoid it (try linking components to public fields in the inspector).