How to test a object for null?

Hello, Iv’e been messing with unity’s 2d pack. In the angry birds style pack, they don’t make the scene reset or load a new scene once the enemy bird dies. I wound up renaming the object to PlayerDemo.

So this is what I have:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class Resetter : MonoBehaviour {
    GameObject PlayerDemo;                  //The object i want to test for null

	public Rigidbody2D projectile;			//	The rigidbody of the projectile
	public float resetSpeed = 0.060f;		//	The angular velocity threshold of the projectile, below which our game will reset
	
	private float resetSpeedSqr;			//	The square value of Reset Speed, for efficient calculation
	private SpringJoint2D spring;			//	The SpringJoint2D component which is destroyed when the projectile is launched
	
	void Start ()
	{
		//	Calculate the Resset Speed Squared from the Reset Speed
		resetSpeedSqr = resetSpeed * resetSpeed;

		//	Get the SpringJoint2D component through our reference to the GameObject's Rigidbody
		spring = projectile.GetComponent <SpringJoint2D>();
	}
	
	void Update () {
        //If the target dies
        if (PlayerDemo == null)
        {
            Reset();
        }
		//	If we hold down the "R" key...
		if (Input.GetKeyDown (KeyCode.R)) {
			//	... call the Reset() function
			Reset ();
		}

		//	If the spring had been destroyed (indicating we have launched the projectile) and our projectile's velocity is below the threshold...
		if (spring == null && projectile.velocity.sqrMagnitude < resetSpeedSqr) {
			//	... call the Reset() function
			Reset ();
		}
	}
	
	void OnTriggerExit2D (Collider2D other) {
		//	If the projectile leaves the Collider2D boundary...
		if (other.GetComponent<Rigidbody2D>() == projectile) {
			//	... call the Reset() function
			Reset ();
		}
	}
	
	void Reset () {
		//	The reset function will Reset the game by reloading the same level
		SceneManager.LoadScene (1);
	}
}

I was hoping that adding the GameObject reference would get the object from the unity editor…
What happens with this code is, when I press play, the scenes constantly switch no-stop. I tried so many different things and I couldn’t figure it out. What am I doing wrong?

PlayerDemo should be public or have the [SerializeField] attribute so you can actually add the reference draging the player into the inspector, or you should find the player object on the Awake or Start method with Find of FindObjectOfType.

Just defining the variable there does nothing. You should be getting a warning in Unity saying that PlayerDemo is never assigned and will have it’s default value (null).