IF Statement Being Ignored

Hello everyone, I’ve come across a problem where one of my IF statement conditions is being ignored, and the code within it is being run even though the condition is false.

The purpose of these scripts is to: disable the player, turn the screen black, move the player to the spawn, and then allow the player to move.

The first code block contains the IF statement that is being ignored [if (screenFadeInOut.proceed == true)]. And the second block is the script that is primarily referenced by the first. Any insight is appreciated.

	void IsPlayerDead ()
	{
		if (isDead || currentHealth<=0f)
		{
			playerMovement.enabled = false;
			Debug.Log ("Player cannot move");

			screenFadeInOut.sceneEnding = true;
			Debug.Log ("Screen getting dark");

			if (screenFadeInOut.proceed == true)
				Debug.Log ("Ending scene now");
			{
				rigidbody.velocity = Vector3.zero;
				Debug.Log ("The player has no speed");
				
				transform.position = lastKnownSpawn;
				Debug.Log ("Moving player");
				
				isDead = false;
				Debug.Log ("Player is now undead");
				
				//screenFadeInOut.sceneStarting = true;
				//Debug.Log ("Starting scene now");
				playerMovement.enabled = true;
			}
	
			//disable controls, fade screen, reset position, reset room objects, turn screen back on, unlock controls
		}
	}

	public void EndScene () 
	{
		if (sceneEnding == true)
		{
		guiTexture.enabled = true;
		FadeToBlack();
			if (guiTexture.color.a >= 0.95f)
			{
				guiTexture.color = Color.black;
				//guiTexture.enabled = false;
				sceneEnding = false;
				proceed = true;
			}
		}
	}

Oh, I just realized something else which is probably the real cause. Notice that you must never put lines of code between an if-sentence and its associated block of code. The reason is that an if-sentence followed by a single line of code (not delimited by curly braces) will be interpreted by the compiler as that if-statement’s block. I.e.:

if(someCondition == true)
Debug.Log("I am the if-statement's block");

Is equivalent to:

if(someCondition == true)
{
    Debug.Log("I am the if-statement's block");
}

And this:

if(someCondition == true)
Debug.Log("I am the if-statement's block");
{
// Code here is not at all associated with the if-statement
}

Is equivalent to:

if(someCondition == true)
{
Debug.Log("I am the if-statement's block");
}
// Code here is not at all associated with the if-statement

To avoid this type of confusion in the future, always delimit all code for an if-sentence by curly braces {}, and do not put anything between the if-statement and its braces.

When used to just encapsulate otherwise free-standing code, curly braces instead define a scope, that is, a section of code with its own memory stack, which cleans up the memory allocated by variables declared inside of it when control flow leaves the scope. Declaring such a scope is what you have unknowingly done in your code above.

Hey,

Ive just noticed, not sure if this is a typo here or its exactly like this in the code BUT :

if (screenFadeInOut.proceed == true)
Debug.Log ("Ending scene now");
{

what it does is : if the proceed is true, it will print Debug info and then regardless of the condition it will start a scope ({) and proceed withe the rest of the code.
What you should to here is :

 if (screenFadeInOut.proceed == true)
 {
    Debug.Log ("Ending scene now");

I dont think this statement is being ignored, but you assume different results.
Why dont you debug the values before and after the statement starts?
Why do you check if player is dead or has < 0 HP? isdead should be the only value which is checked, anything else is no good way to handle this state.