So im making a clicker game and in the upgrader script i need to know how to get the cash value and stuff from another script, im very new to unity and C#, any help?
Try this:
public OtherScriptsName otherScript; //Change the type to the name of the script
void Start() {
otherScript.variable = 12; //Setting a variable in otherScript
print(otherScript.variable); //Getting the value of a variable in otherScript, print was used for demo purposes and is not needed
}
In script, which you want get values you must write some functions or variables. These elements must be public.
In script, which you want to get access to values you must to use yourScript.GetComponent<YourScriptClass>().valueWhatYouWant.