Anyone know what's wrong with this code? (SOLVED)

I keep getting a error on this code. It says:
‘isBuild’ is not a member of ‘UnityEngine.Component’. it occurs on line 15
For some reason I can’t get a straight answer, Thanks if you know.

#pragma strict
    var Prefab : Transform;
    function Start  () {
    
    }
    
    function Update () {
    
    }
    function OnGui  () {
    if (GUI.Button (Rect (10,10,150,100), "Create")) {
    var gos : GameObject[];
        gos = GameObject.FindGameObjectsWithTag("SetObject");
        for (var g in gos){
        if (g.GetComponent("here the name of the Script").isBuild);
        Instantiate(Prefab, g.transform.position, Quaternion.identity);
        Application.Quit();
    }
    	}
    		}

GetComponent() returns a Component. That’s a Unity base class. When you create a script, it inherits from Component. The script you create has extra members, of course, so, in your example, it looks as though your script has a member called isBuild. When you use GetComponent() to find your script, you can do:

var s : YourScript = g.GetComponent(YourScript) as YourScript;
if (s.isBuild) {
    //blah

This grabs the component, and casts it to YourScript, which has the isBuild member. Alternatively you can use the generic version:

var s : YourScript = g.GetComponent.<YourScript>();
if (s.isBuild) {
    //blah

which does the exact same thing. Obviously you’d check that s has a value before using it.

I don’t use JS and I’m going on a limb here but try something along the lines of:

if (GUI.Button (Rect (10,10,150,100), "Create")) {
    var gos : GameObject[];
    gos = GameObject.FindGameObjectsWithTag("SetObject");
    for (var g in gos){
        var temp : ScriptName;
        temp = g.GetComponent("here the name of the script");
        if(temp.isBuild()){
            Instantiate(Prefab, g.transform.position, Quaternion.identity);
        }
        Application.Quit();
    }
}

Okay I have another problem :stuck_out_tongue: My Script won’t work at all! xD
I have it applied to my camera The whole Script is:

var Prefab : Transform;
function OnGui () {
	  if (GUI.Button(Rect(10,10,50,50),"Create")){
			var gos : GameObject[];
    		gos = GameObject.FindGameObjectsWithTag("SetObject");
    		for (var g in gos){
    		if (g.GetComponent.<ControlObject>().isBuild);
    		Instantiate(Prefab, g.transform.position, Quaternion.identity);
			}
		}
	}

I don’t see anything wrong with it… I even tested to see if it was working by putting: 'Application.Quit();' in the start function and it still didn’t do anything :confused: once again i have this script on my camera. Anyone have a idea on what may be causing this?
Thanks if you can help! :smiley:

can you see in the inspector that when running the scene you have an object with tag “SetObject”?

Im editing my own answer now as somebody said it is not an answer but a comment

it could be that the code is calling a tag which is not existing.