DontDestroyOnLoad

On the start screen (first scene) of my game player can disable sound using checkbox.
It’s value stored in the variable toggleValue.

When I load game (second scene) and then load first scene again, I can see, that toggle’s value is like it was when I launched the game.

Can’t understand, what’s wrong.

public Toggle toggle;
public bool toggleValue;

void Awake() {
	DontDestroyOnLoad (this);
}

public void GetToggle() {
	Debug.Log (toggle.isOn);
	toggleValue = toggle.isOn;
}

Edit1:

Options.cs (first scene)

private static Options _Instance = null;
public Toggle toggle;
public bool toggleValue;

void Awake () {
	if (_Instance == null) {
		DontDestroyOnLoad(this);
		_Instance = this;
	}
	else
		Destroy (this.gameObject);
}

public void GetToggle() {
	toggleValue = toggle.isOn;
}

OptTest.cs (second scene)

Options myOptions;

void Strat() {
	myOptions = (Options) GameObject.FindObjectOfType(typeof(Options));
}

void Update() {
	if (myOptions != null)
		myOptions.toggleValue = false;
	else
		Debug.Log("Options could not be found");
}

Since DontDestroyOnLoad doesn’t destroy the gameObject, I’m going to guess when you return to “First scene” there will be a duplicate gameObject with this script on it. And that duplicate is overwriting whatever changes you made to the first gameObject.

Try this:

private static NewBehaviourScript _Instance = null;

void Awake () {
	if (_Instance == null) {
		DontDestroyOnLoad(this);
		_Instance = this;
	} else {
		Destroy (this.gameObject);
	}
}