Monobehaviour as a varibale with Reffrence

Hi:
I would like to add a script to a var as below. then be able to assess it. Is this possible?

First Script:

public class FirstScript: MonoBehaviour
{
         private MonoBehaviour script; //works
    
         void Awake()
         {
              script = gameobject.Getcomponent<SecondScript>(); //works
         }
    
         void ThisMethod()
         {
              script.someVar = 99; //here is my problem!
              script.Use(); //here is my problem! 
         }
}

Second Script:

public class SecondScript: MonoBehaviour
{
     public int someVar;

     public void Use()
     {
           print("used");
     }
}

I cant seem to access the script variables and methods this way and would like to due to being able to change scripts. All the scripts will have “someVar” and “ThisMethod”. or am I trying something that is not possible?

This is a C# thing - your field should be of the derived type, not base class (Monobehaviour):

instead of:

private MonoBehaviour script;

use:

private SecondScript  script;

then:

script.Use();

Otherwise, if you add your SecondScript (derived from MonoBehaviour) to field of type MonoBehaviour, Unity won’t have any idea about Use() method or someVar, as such does not exist in MonoBehaviour.