accesing variable from other script

I have been trying to access variable speed (and change it) which is in script A from script B.

i read threads on forums and on the internet, but nothing seems to work.

There are multiple ways to do this.

Just go to this page: Unity Doc and hit CTRL + F and type in “Find”. All of these methods will find a gameobject based on a string. Then you just use GetComponent<>()

Using GetComponent<>() you can achieve it.

If you’re using C# make your variable as Public static int (or) some other data type, and access from another script.

I despise Java but i think what your looking for is a global or public variable in which i think is declared above your start() and update() blocks this should be able to be accessed from another script you may need to use .find method when calling it.

EDIT

Found this tutorial that may help.

Unity Tutorial 6 - Accessing scripts

I finally got it working with

GameObject.Find("diger").GetComponent(movement).speed = 5;