Not sure how to explain that better in the title, but here is what my problem is and im not sure how to get around it with my basic scripting knowledge.
I want to play a sound file at the same time my gui is displaying an error. The error is displayed while a variable is true. If i put the audio call in this part of the function it stutters and repeats the whole time this condition is true.
function OnGUI ()
{
GUI.DrawTexture(Rect(0, Screen.height - 64, Screen.width, 64), backText); // bottom banner bar
GUI.Label (Rect (20,10, 400, 64), "Press F2 for Help", textStyle1);
if (warning == 1)
{
audio.Play();
GUI.Label (Rect (20,Screen.height - 160, 400, 64), "Warning!", textStyle2);
GUI.Label (Rect (5,Screen.height - 133, 400, 64), texty, textStyle1);
}
}
What would be the correct way to maybe make another function but only call it once from this function so it plays only once. I know there are going to be a few eye rolls, sorry for that 
You might want to call audio.Play() from the same code block where you set warning equal to 1. The reason you don’t want to do as you’re doing now is because OnGUI is called multiple times per frame, thus calling audio.Play() multiple times per frame… bonk! 
OnGUI() is called every frame. Since the Play() is being called in OnGUI(), you’ll start the clip over every frame, resulting in that stuttering noise. You could try something like this:
var alreadyPlayed = false;
function OnGUI ()
{
GUI.DrawTexture(Rect(0, Screen.height - 64, Screen.width, 64), backText); // bottom banner bar
GUI.Label (Rect (20,10, 400, 64), “Press F2 for Help”, textStyle1);
if (warning == 1)
{
if(!alreadyPlayed)
{
audio.Play();
alreadyPlayed = true;
}
GUI.Label (Rect (20,Screen.height - 160, 400, 64), “Warning!”, textStyle2);
GUI.Label (Rect (5,Screen.height - 133, 400, 64), texty, textStyle1);
}
Adding the alreadyPlayed bool should make it so the sound only plays once.
Yea i was sort of trying to avoid that because i have many error calls and was hoping to put it here to simplify things but your right, that is the best way. Ok off to sift through the scripts! Thanks again, you always seem to come to my aid!