play audioclip problem

Hi there, when I raycast my object it will show me the GUIDrawTexture and when i’m not hitting the object my audioClip will play.

I need the audioClip to play when the GUIDrawTexture is shown (like at the same time). dont know what i’m doing wrong see my code

function Update () {
         if (Physics.Raycast (transform.position, transform.forward, hit, 100))  
         {
           if(hit.collider.gameObject.tag == "kat")
           {
           	hitter = true;
           	{
           	Print("I am looking at" + hit.transform.tag);
           	audio.clip = audioKat;
        	   audio.Play();
        	   }		
           }
         }
}



 function OnGUI() {
	if(hitter == true && hit.collider && hit.collider.gameObject.tag == "kat")
	{
		GUI.DrawTexture(position, katImage); //"draws" image		
	}
}

You are telling the audio clip to start playing for each frame that the raycast hits the object. When you look away, it finally has a chance to play the object. You want the Play() method to be called once, so use audio.isPlaying() to check the status.

Note: You will need to add some other sort of flag (bool) that says it has played already, and set it to false when you look away otherwise extended periods of time will just play the sound over and over.