Disabling a script from another script

Hey guys I have this code that gives me the error:

“Object reference not set to an instance of an object.”

using UnityEngine;
using System.Collections;

public class GUITextScript : MonoBehaviour {
   
    private bool guitex = false;
    public Texture starmap;
    public Texture starmapdeclined;
    public Camera maincam;
    public Camera starmapcam;
    public CharacterMotorC disablecode;

    void OnTriggerEnter(Collider other) {
        guitex = true;
    }
   
    void OnTriggerExit(Collider other) {
        guitex = false;
        maincam.camera.enabled = true;
        starmapcam.camera.enabled = false;
    }
   
   
   
   
    void OnGUI(){

    disablecode = GetComponent<CharacterMotorC>();

        if (guitex == true)
        {
            GUI.DrawTexture(new Rect(Screen.width/2-256, Screen.height/2-128, 512, 256), starmap);

            if (Input.GetKeyDown(KeyCode.E))
            {

                guitex = false;
                maincam.camera.enabled = false;
                starmapcam.camera.enabled = true;
                disablecode.enabled = false;

            }


        }
    }
}

I am getting the error on line 40, while trying to disable another script through this script. Any ideas what might be causing this? Thanks.

only way that code would populate “disablecode” is on line 28, so that’s the bit that isn’t working… make sure there is a “CharacterMotorC” component on the object, correct spelling etc.

I agree with LeftyRighty, maybe the object that is running this GUITextScript doesn’t have CharacterMotorC script.