Call method from another script

So i need to call a method in another script in a onpointerclick method i tried it like this:
MyScript script = new MyScript();
script.MyMethod();

but then i always get a null reference error. I already tried someother ways like creating a global variable in my script and getting MyScirpt with GameObject.Find(“MyGameObject”).GetComponent(); but then even though the gameobject exists the code cant find it. It would be great if some one could help me since im trying to do this for about 2 to 3 days now. Thank You for your help :slight_smile:

MyGameObject.GetComponent().MyMethod();

1 Like

thank you man had to change it a bit but now it finaly works