How to call a script with out instantiating it.

I have a pickup script. I have a script on objects that will get picked up. I want the object’s script to call a function where the players pickup are stored. So basically I need a script to call another’s script function. This is in C# but if you tell me how to do it in javascript I can figure out how to do it in C# without help.

I want the function changer to be called

using UnityEngine;
using System.Collections;

public class objectStorage : MonoBehaviour {

	public int sphere = 0;
	
	public static void Changer(int amount)
	{
		//change the amount of spheres
		sphere+=amount;
	}
}

and it will be called fromt his script

using UnityEngine;
using System.Collections;

public class pickupObject : MonoBehaviour{
	
	public GameObject controller;
	public bool debug = false;
	public bool debug1 = false;
	

	void OnTriggerStay(Collider collision)
	{
		if(collider.gameObject.tag == "Pickup")
		{
			debug = true;		
			if(Input.GetButtonDown("Pickup"))
			{
				print ("Destroyed the object");
				controller.GetComponent<objectStorage>().Changer(1);
				Destroy(collider.gameObject);
			}
		}
				
	}
}

You are attempting to modify an instance variable (sphere) with a static method. This is not possible.

I’m not quite sure what you are trying to do, but I suspect you want a ''singleton" Singleton pattern - Wikipedia . Note that you do not have to subclass from MonoBehaviour for such a class, though usually there is no reason not to as it makes runtime debugging in the editor easier.