Passing a Script Name to a Function

Is this possible? I’d like to be able to input the script name as a parameter in the function like so:

function CacheScript(someVariable : scriptName[], anotherVariable : scriptName)
{
   for (var i : int = 0; i < gameObject.Length; i++)
   {
      someVariable _= gameObject*.GetComponent(anotherVariable);*_

}
}
Problem is figuring out which type to declare for “someVariable” and “anotherVariable” since I won’t know the variable type until I enter the custom script name when I call the function. I’ve tried researching all the different types I could use to declare the variable type but coming up empty. Any help would be hugely appreciated!

You should be able to use UnityEngine.Object (or just Object) instead of String.

Have you tried making someVariable an array of Components instead of Strings?

You might also consider GameObject.GetComponentsInChildren if the target game objects are children of the object running the query.