Static variables not working inside Function Update()

Hello ! Well, I have a big problem that I can’t solve by any way and all I find on the internet is resolving the problem by the same way and it doesn’t work for me.

If you get a static variable with the GetComponent stuff like explained in the Tutorial section of the website you have to put it inside Function Update() (if you don’t, Unity calls an error). But it’s okay, I went ahead of it. However, if now I want to use that variable inside a Function MonoBehaviour(), Function [any type of collision/trigger] or just somewhere else than inside Function Update(), the system shows an error.

I write some codes line right under to explain it beter.

function Update() {

   var totems:Totem = GetComponent("Totem"); // Totem is how my other script is called
}

function OnCollionEnter(){

   if(totems.totem1==true){ // totem1 is a static boolean variable

      //Do Something
   }

}

If you have a static variable then you will not need any instance of this script to call this static variable. lets say you got a non static variable in a script:

Script.js

var anthing :boolean;

_______________________

var sc :Script = GetComponent("Script");
var anythingInThisScript :boolean = sc.anything;

if it is static the only thing you should do is to pack the variable in a class:

Script.js

class Totems
{
 static var totem1 :boolean;
}

------------------------

anyScript.js

function Update() //or any other
{
  var totem1 :boolean = Totems.totem1; //no instance of this class or script is necessary
}

I hope you understood it:

static variable → no instance of this class or script. It is “static” and in each instance the same

non-static variable → can be changed from instance to instance and is “non-static”. You need to have an instance of the class/Script to get/change the variable