static var for one object.

I’m looking for a way in java script to change the static variable from a separate script only on the script of one object, that object is a variable (transform var or gameObject var ect.)

this is what i thought would do it but no luck, only errors:

var object : GameObject;

function Update () {
     object.ObjectScript.StaticVar += 1;
}

There’s no such thing as a static var for only one object (unless the object that has the script with that variable is a singleton). A static var in a script will only hold one value across all objects that use that script… which is why the syntax for accessing static variables is the way it is.

You probably want to make that variable a public member variable, and then access it via GetComponent, a la:

object.GetComponent(ObjectScript).publicVar += 1;

Static stuff is not part of the object itself. Static variables or methods belong to the class, not to an instance of that class. There is only one class of that type. If you need data that belongs to an instance remove the static to make it an actual member of the object.