Mute volume / sound problem

okay my problem is when i press the mute button it works fine and unmute is fine but the problem is ive set it with a picture button but what happens is when I mute it and go to the next scene and go back again the volume is still muted but the button for it is for not muted okay here’s my code

void OnGUI(){
if(yMute){
			if (GUI.Button(new Rect(100, 10, 100, 50), "",Y))
			{
				AudioListener.volume = 0.0F;
				muted = true;
				nMute = true;
				yMute = false;
			}
		}
		if(nMute){
			if (GUI.Button(new Rect(100, 10, 100, 50), "",N))
			{
				AudioListener.volume = 1.0F;
				muted = false;
				nMute = false;
				yMute = true;
			}
		}
	
	}

	void Start () {
		yMute = true;

	}
	
	// Update is called once per frame
	void Update () {
		if (yMute == true) {
			nMute = false;
		}
		else {
			nMute = true;
		}
	}
}

so what I need is when i press my mute button the picture will change for the unmute and when i press it again the unmute will change for the mute picture it works fine but when i go to the next scene and go back here again the volume is muted but my button is for not muted so how can i fix that ? please help me thank you

The problem is that your using multipe variables to detect if user have alredy muted or not the sound. And you reset to false yMute variable at Start, so when you back to the scene, yMute is set to true, but nMute keep his old value.

Use only one variable would be better, something like:

void OnGUI()
{
	if(!isMuted)
	{
		if (GUI.Button(new Rect(100, 10, 100, 50), MuteImage))
		{
			isMuted = true;
			AudioListener.volume = 0.0F;
		}
	}
	else
	{
		if (GUI.Button(new Rect(100, 10, 100, 50), unMuteImage))
		{
			isMuted = false;
			AudioListener.volume = 1.0F;
		}
	}
}