Missing Component Exception


I have run into an issue when trying to call a sound on a mouse click of a GUI button. I am getting "MissingComponentException" error from the line that calls the audio. I have attached the audio to the AudioClip variable multiple times and even have this audio call and audio clip working in another scene. I have also tried detaching and reattaching the script to my Camera and restarting Unity with no success. Posted below is the code I am using, the audio is being called in the loadIntro() function at the bottom. Thank you.


var directionsTxt : Texture2D;
var directionsWidth : int = 1024;
var directionsHeight : int = 768;

var exitDownSound: AudioClip;

private var isLoading = false;

function OnGUI(){
        GUI.skin = gSkin;
        Debug.Log("startMenuGUI: GUI Skin object missing!");

    var backgroundStyle : GUIStyle = new GUIStyle();

    backgroundStyle.normal.background = backdrop;

    var directionsStyle : GUIStyle = new GUIStyle();
    directionsStyle.normal.background = directionsTxt;

    GUI.Label(Rect(0, 0, Screen.width, Screen.height), "", backgroundStyle);
    GUI.Box(Rect(Screen.width/2 - directionsWidth/2,Screen.height/2 - directionsHeight/2, directionsWidth, directionsHeight), "", directionsStyle);
    GUI.Label(Rect(0, 20, 600, 100), "", "directionsMenuTitle");

    if(GUI.Button(Rect(Screen.width*0.5 - buttonWidths/2, Screen.height - 80, buttonWidths, 70), "exit")){
        isLoading = true;

        GUI.Label(Rect((Screen.width*0.5)-110, (Screen.height*0.5)-60, 400, 70), "Loading...", "directionsMenuTitle");
function loadIntro(){
    yield WaitForSeconds(2);

@script ExecuteInEditMode()


Forgive me if I'm missing something but the error is pretty darn clear. :) Add an audio source component, just like the error says to if you want to do things like call audio.PlayOneShot().

Select the game object and then go to Component > Audio > Audio Source to add that component.

Yeah of course I took a stab at adding an Audio Source to the camera as soon as posted this to the forum. Somehow I managed to look in every corner of the Forums/Reference/3D Tutorial without taking a gander at Audio Source. Sorry bout that, still very new at this.

Next time read the error, love the error, respond to the error! :P

Rock on and keep having fun!

Hello there,

I have run into an issue when trying to call an animator on a character for a game. I'm getting a "MissingComponentException" error from the line that calls the animation movement for my character. I attached an animator onto my selected character, but it says it is not attached, but a script is trying to access it. Posted below will be some screen shots of my code, along with the components I used. Thank you.8060939--1041116--Script Animator.PNG 8060939--1041119--CharScript 1.PNG 8060939--1041122--CharScript 2.PNG 8060939--1041125--CharScript 3.PNG 8060939--1041128--CharScript 4.PNG