Enabling A Script From A Script NOT Working

Hi everyone of the internets, I’m here to ask a questions that MIGHT have a VERY simple answer, but I just can’t figure it out. So basically I’m creating a FPS with my friends, but I have ran into a problem with a script. Here’s the script:

using UnityEngine;
using System.Collections;
using UnityStandardAssets.Characters.FirstPerson;

public class PlayerNetworkMover : Photon.MonoBehaviour 
{
	public delegate void Respawn(float time);
	public event Respawn RespawnMe;
	public delegate void SendMessage(string MessageOverlay);
	public event SendMessage SendNetworkMessage;

	public float health = 100f;
	Vector3 position;
	Quaternion rotation;
	float smoothing = 10f;
	bool aim = false;
	bool sprint = false;
	bool initialLoad = true;
	
	Animator anim;
	
	void Start()
	{

		anim = GetComponentInChildren<Animator> ();
		if(photonView.isMine)
		{
			transform.Find ("MainCamera/Camera/Ak-47").gameObject.layer = 9;
			transform.Find ("MainCamera/Camera/Ak-47/Ak47Body").gameObject.layer = 9;
			transform.Find ("MainCamera/Camera/Ak-47/Ak47Mag").gameObject.layer = 9;
			transform.Find ("MainCamera/Camera/Ak-47/Cube_001").gameObject.layer = 9;

			GetComponent<RigidbodyFirstPersonController>().enabled = true;
			GetComponent<Rigidbody> ().useGravity = true;
			GetComponent<Crouching>().enabled = true;
			GetComponentInChildren<PlayerShooting> ().enabled = true;
			GetComponentInChildren<AudioListener> ().enabled = true;

			
			foreach(Camera cam in GetComponentsInChildren<Camera>())
				cam.enabled = true;
		}
		else
		{
			StartCoroutine("UpdateData");
		}
	}

It’s the start of a script copied from the Unity Merry Fragmas Live Tutorial, edited to fit my needs. So the problem is in this line:

GetComponent<RigidbodyFirstPersonController>().enabled = true;

It’s properly located in the inspector as seen:

but when I run the game, Unity gives me a Object reference not set to an instance of an object error.

And I CAN’T figure out why. So if anyone with the powers of Unity far beyond me can help, it would be much appreciated.
Thanks For Reading!

The ‘NullReferenceException: Object reference not set to an instance of an object’ tells you that whatever you’re referencing to is an Object and not an instance of it - which it has to be.

This would be the same as trying to reference to a class Dog and try to call a function or method on it, which you can’t because it’s the class itself and not an instance of it. The class kinda holds the recipe for how to make - in this case - a dog. While the instance itself is when you have created an actual dog.

So! What you have to do is that you should make an instance of the script you’re trying to access and then do what you want to do on that instance of it. Let me show you how:

RigidbodyFirstPersonController myRigidbodyFirstPersonController = GetComponent<RigidbodyFirstPersonController>();
myRigidbodyFirstPersonController.enabled = true;

I hope this helped you. You both solved this problem and now know how to solve the ‘NullReferenceException: Object reference not set to an instance of an object’ in the future.

Peace!