How do I reference variables from other class files?

I am trying to reference a boolean value from the javascript file: ItemBools. In ItemBools, there is a public variable named isAxeFound. In another class called AxeCollisionScript, I need to change the value of isAxeFound that is stored within the javascript ItemsBool. I tried referencing the variable by using the line: ItemsBool.isAxeFound = true; , but that doesn’t work. If you need to see code, I can submit it, but I thought it was simple enough to understand. Thanks!

If both of these scripts are attached to the same game object, you can use GetComponent(). So from within your AxeCollisionScript, add this line:

gameObject.GetComponent(ItemBools).isAxeFound = true;

If these scripts are not attached to the same object, I’m going to need more information.

Also, check this doc for more details: Unity - Scripting API: GameObject.GetComponent