Is there any way to change a variable in one script by using another script?
There is a very simple way to achieve this using Public Static Variables
You can Create A public Static Variables in the Script so that they can accessed in other Script as well as their value modified
Here is the simple example:
public static int score;
Just for understanding assume that this variable is in Script called global.cs. Now you can easily access this variable anywhere(in any script) using
int getscore=global.score;
Now to change this score variable which is in the global.cs file. You can simple do this
int newscore=10;
global.score=newscore;
or even directly just by this code
global.score=10;
Tell me in Comments if your doubts are not solved.
Take a look at this
You just need to find the object, get the component that you want (your script), and, in this create a method to change the variable, or just change it, if its public.
Edit: Link Updated. Thanks OnyDeus - Meat5000