What the hell??
So first off I want to say that there is probably nothing wrong with the code. Today I was working on my project. I was trying to add sound effects to my other objects… And I did. And then suddenly 2 errors popped up. On both of these errors I was basically trying to play Audio through script.

‘AudioSource’ does not contain a definition for ‘clip’ and no extension method ‘clip’ accepting a first argument of type ‘AudioSource’ could be found (are you missing a using directive or an assembly reference?

‘AudioSource’ does not contain a definition for ‘Play’ and no extension method ‘Play’ accepting a first argument of type ‘AudioSource’ could be found (are you missing a using directive or an assembly reference?)

Here is my code but again, there is 100% nothing wrong with it since it worked fine before. Also its not completely the same as I changed it a bit after trying to solve the problem. But either way the script is probably alright.

public void ChangeLevel()
    {
        StartCoroutine(delayedLoad());
    }

    private IEnumerator delayedLoad()
    {
        AudioSource audio = GetComponent<AudioSource>();
        audio.clip = OtherClip;
        audio.Play();
        Player.SetActive(false);
        FadeOutPanel.SetActive(true);
        FadeOutAnim.enabled = true;
        yield return new WaitForSecondsRealtime(0.45f);

        SceneManager.LoadScene(0);
    }

So does anyone have any idea how could these errors just pop up after adding couple AudioSource components to gameobjects?

Thanks.

UPDATE!!

If I try…

 AudioSource audio = GetComponent<AudioSource>();
        if(audio == null)
        {
            print("AUDIO NOT RECOGNIZED");
        }
        else if(audio != null)
        {
            print("AUDIO RECOGNIZED");
        }

it prints message AUDIO NOT RECOGNIZED, that means that even though Audio source component is attached it doesnt recognize it.

Did you by any chance rename your script as AudioSource.cs?