Cannot implicitly convert type 'void' to 'bool

At the moment a background Audio is playing over all scenes. But I want only a few scenes to play it. I try to fix it with an if-query, but it only says “Cannot implicitly convert type ‘void’ to 'bool”, how can I fix it?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Audio : MonoBehaviour {

static Audio instance = null;

private void Awake()
{
if (instance != null) {
Destroy (gameObject);

}
else {
instance = this;
if (SceneManager.LoadScene (“Dodge!”)) {
GameObject.DontDestroyOnLoad (gameObject);
}

}
}

public void ToggleSound()
{
if(PlayerPrefs.GetInt(“Muted”,0) == 0) {
PlayerPrefs.SetInt (“Muted”, 1);
//AudioListener.volume = 1;
}
else
{
PlayerPrefs.SetInt (“Muted”, 0);
//Audiolistener.volume = 0;
}
}

}

Read your error message!

You’re trying to use something that is a [void](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/void) as a [bool](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/bool). LoadScene does not return a bool but a void, so you cannot test it. You want to change that to a check that does is-this-the-scene-loaded.

Check out this thread for future posts… use code tags so your code is nicer to read: Using code tags properly