AudioSource dissappears in variable window on Play

I have a script that is supposed to play an audio clip once the player enters a trigger. My script is very closely based upon the one in the Scripting API. I have watched tutorials as well and they have scripts that are the same as the one in the API.

#pragma strict
public var leaves: AudioSource;

function Start(){

    leaves = GetComponent.<AudioSource>();

function OnTriggerEnter(col : Collider) {
    if( == "First Person"){

The source’s volume is up, and there is a clip attached to it. The fact that I have it looking for a specific collider doesn’t cause any issues because I’ve troubleshot that already.

I have the source drag/dropped into the variable window on the script.


Though once I hit the Play button, the audio source dissappears from the variable window. I can drag the audio source back into it while in play and the script works perfectly. Yet, nothing saves when in play mode.

To the best of my knowledge, I’m doing everything correctly. I just wonder if there’s something in the script causing the audio source to be removed, or a setting in the editor perhaps.

Thanks for the help!

I guess it’s because " GetComponent.();" return null


I realized what was wrong. The AudioSource needed to be a component of the trigger instead of a separate game object. smh

Thanks for your help!