Cannot disable a script from another script?

We are trying to disable the visibility of the menu on a separate script from a different script. We wrote:

public JoshsMenu menuState;
	void Start () {
		
		menuState = GetComponent<JoshsMenu> ();

		menuState.enabled = false;
	}

But we are still getting error:
NullReferenceException: Object reference not set to an instance of an object.
It stems from the line:
menuState.enabled = false;
Thank you for tolerating our naiveté.

@FarmerJoe

Here your GetComponent is not valid.

This script JoshMenu is attached to a GameObject… Right ?? And you need to disable the script of that Gameobject… (assume that the joshMenu attached gameObject is different)

for that you could use,

	gameObject.GetComponet< JoshMenu >().enabled = false;

If the JoshMenu script and the current script are attached to the same gameObject, then you may use:

GetComponet< JoshMenu > ().enabled = false;

use this

public GameObject otherobj;//your other object
	public string scr;// your secound script name
	void Start () {
	(otherobj. GetComponent(scr) as MonoBehaviour).enabled = false;
	}

To be able to use GetComponent the script would have to be on the same object that you are calling from.

If you assign the variable in the editor before entering Play mode just remove the line where you try to get it.