Setting the variable on a GameObject to be instantiated (not yet existent) cs and js

I'm trying to set an exposed variable on a gameobject that has not yet been instantiated.

var s:GameObject=GameObject.Find("instantiateMe");
var instances:GameObject;
instances = Instantiate(s,pos,rot);
instances.GetComponent(ScriptName).id=id;

Using the usual method above, I get this fatal error: "BCE0005 Unknown identifier: ScriptName"

`instantiateMe` (the object to be instantiated) has a script named `ScriptName` in it, with the global variable `id`...


Using this method, I get "BCE00018: The name 'ScriptName' does not denote a valid type ('not found')."

var s:GameObject=GameObject.Find("instantiateMe");
var instances:GameObject;
instances = Instantiate(s,pos,rot);
var script:ScriptName=instances.GetComponent(ScriptName);
script.id=id;

ScriptName.cs is a cs file! But, I'm using js on the other ones as I am more familiar with that.

It looks like you haven't defined the variable ScriptName anywhere in your code. GetComponent takes a string as a parameter not a type so you would have to write:

instances.GetComponent("ScriptName").id = id;

Try creating a folder called "plugins" or "Plugins" (not sure if capitalization is important) and putting your .cs files in there. THat'll cause them to be compiled earlier than most other scripts, and your .js files will know about their variables.