C# script error please help

unity keeps giving this error:: Assets/_Scripts/startbutton.cs(18,14): error CS1624: The body of startknop.OnMouseUp()' cannot be an iterator block because void’ is not an iterator interface type

i am prety new to coding so please help me.

using UnityEngine;
using System.Collections;

public class startbutton : MonoBehaviour {
	public string levelToLoad;
	public AudioClip soundhover;
	public AudioClip beep;
	public bool QuitButton = false;

	void OnMouseEnter(){
		audio.PlayOneShot(soundhover);
		transform.renderer.material.color = Color.black;
	}
	
	void OnMouseExit(){
		transform.renderer.material.color = Color.red;
	}
	void OnMouseUp(){
		audio.PlayOneShot(beep);

			
			yield return new WaitForSeconds (0,25);
			if(QuitButton){
				Application.Quit();
		
		}
		else{
			Application.LoadLevel(levelToLoad);
		}
	}
}

It is all in your error, you have a yield in the method and yield requires the return value to be IEnumerator but yours is void so clash.

bool noTwoCoroutine = false;
void OnMouseUp(){
   if(noTowCoroutine == false)
       StartCoroutine(CoroutineMethod());
}

IEnumerator CoroutineMethod(){
   noTwoCoroutine = true;
   audio.PlayOneShot(beep);
   yield return new WaitForSeconds (0,25);
   if(QuitButton){
       Application.Quit();
   }
   else{
       Application.LoadLevel(levelToLoad)
   }
   noTwoCoroutine = false;
}

Two things, you can’t yield out of a function that’s not an IEnumerator in C#

Also, the function call for WaitForSeconds takes a float, and I’m not sure '0,25' will compile correctly.

The solution would probably be to do something like this:

void OnMouseUp()
{
    StartCoroutine(QuitOrLoad());
}
 
IEnumerator QuitOrLoad()
{
    audio.PlayOneShot(beep);
    yield return new WaitForSeconds (0.25f);
  
    if(QuitButton)
    {
          Application.Quit();
 
    }
    else
    {
         Application.LoadLevel(levelToLoad);
    }
}