Need help referencing another script and gameobject without drag and drop method

Hi, im fairly new to Unity and C#, but have done enough of it in the past couple months to understand how to write it, but im having trouble. I want to call a function from another script without making it public and drag dropping it from the editor. Ive had it setup as public ScriptName Name, then drag drop an object with the script. I would like to avoid having to set all these from within the editor, so right now, Im using this:

public class GUIMenuButtonsScript : MonoBehaviour {
	
	private CameraFollowPlayer script1;
	private ShipMove ship;

	void Start()
	{
		script1 = GetComponent<CameraFollowPlayer>();
		ship = GetComponent<ShipMove>();
        }

So when I type something like ship.Firelaser(); it autocompletes it. but in game, it throws an error when trying to do it.

NullReferenceException: Object reference not set to an instance of an object
GUIMenuButtonsScript.OnTouchDown () (at Assets/GUIMenuButtonsScript.cs:59)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
TouchInput:Update() (at Assets/Scripts/TouchInput.cs:62)

Also, How would I write this without having to drag drop it in editor?
This is my current working code to use with drag and drop:

public GameObject goFixed;

public void CameraToggle ()
	{
		if(goFixed.activeSelf)
		{
			goFixed.SetActive(false);
		}
		else
		{
			goFixed.SetActive(true);
		}

the reason I want to do it another way is because I use the same script for all the menu pages and I have to redo the drag drop for each one and getting to be a mess. Ive been rewriting everything to better optimize and organize it, so im not losing time chasing down problems.
Thanks

}

What you showed in your first part of code is right, it autocompletes because ShipMove is a known type so Firelaser() is a known method from that script. However, when you initialise it (ship = GetComponent();), it doesn’t seem to be found, as referred to by the null reference exception. Is the ShipMove script attached to the same GameObject as the GUIMenuButtonsScript ? If not, then this is why you can’t access it directly and need to either put them on the same GameObject or have something along the lines of:

ship = GameObject.Find("MyObjectWithShipMoveAttached").GetComponent<ShipMove>();

Same goes for the other script you declare.

Just to add something :
If you use a tag on your item, it will be faster to access it than looking through all the objects for a specific name.
Using ship = GameObject.FindGameObjectWithTag("MyObjectWithShipMoveAttached").GetComponent<ShipMove>();

Ship is its own script on its own object, not a child of guimenubuttons gameobject. But makes sense now that you said it, It didnt dawn on me that GetComponent is only getting the component of the parent. Ill give this a try thanks.

Didnt know that, I have tags for other objects but thought it would be easier and pretty much the same just to search by name. I still have a lot to learn lol. Thanks