how to call the script of an object being collided with a trigger2D

Hi, I am running in to a little trouble here.
I am getting this error:
error CS0176: Static member `localVariables.test()’ cannot be accessed with an instance reference, qualify it with a type name instead

void OnTriggerStay2D (Collider2D other){
int num = other.gameObject.GetComponent(“localVariables”).index;//something is wrong here <<<

i have an object called a(Clone), clone objects.
when it is colliding with a trigger2D box, I want to get that objects int index, which is inside it’s own script called localVariables.

public class localVariables : MonoBehaviour {
public static int index;

Am I calling the object correctly? What is wrong here?

Make it public int index . Remove static from index . Static members are called with Class Name not with class instance.

and change