NRE when accessing another script?

I’ve been messing around with the 2D tutorial put out by Unity, and I’ve moved some objects away from their parents. In the health script, I’m trying to access the Gun script, which is on another game object. Here’s the part of the script that it’s on:

			// If the player doesn't have health, do some stuff, let him fall into the river to reload the level.
			else
			{
				// Find all of the colliders on the gameobject and set them all to be triggers.
				Collider2D[] cols = GetComponents<Collider2D>();
				foreach(Collider2D c in cols)
				{
					c.isTrigger = true;
				}

				// Move all sprite parts of the player to the front
				SpriteRenderer[] spr = GetComponentsInChildren<SpriteRenderer>();
				foreach(SpriteRenderer s in spr)
				{
					s.sortingLayerName = "UI";
				}

				// ... disable user Player Control script
				GetComponent<PlayerControl>().enabled = false;

				// ... disable the Gun script to stop a dead guy shooting a nonexistant bazooka
				GetComponent<Gun>().enabled = false;

				// ... Trigger the 'Die' animation state
				anim.SetTrigger("Die");
			}

Here is the error:

NullReferenceException: Object reference not set to an instance of an object
PlayerHealth.OnCollisionEnter2D (UnityEngine.Collision2D col) (at Assets/Scripts/PlayerHealth.cs:67)

And since I only gave a part of the code, this is the line it’s pointing to:

GetComponent<Gun>().enabled = false;

When the health reaches zero, it is trying to disable the gun script, which is attached to the gun game object. Apparently, it can’t find the gun script. So how do I fix dat?

Thanks in advance for your time and help.

Got it! For those wondering, I made a variable to hold the gun gameobject, which I called gun, and then changed the line with the error to this:

gun.GetComponent<Gun>().enabled = false;

This be C# by the way.