Reference other scrips in prefab

Hi there. I’m trying to create a script that displays text above all of the objects with the Tag “Building”. So far, I’ve got a prefab and a script that instantiates that prefab for every building in the level, which works. The problem I’m having is that I want to assign each instance of the prefab to a building and display that text.

So what I’m asking is that I want to take a variable from one script, and put it into a variable inside a prefab, but I don’t know how to access a script since I can’t edit the inspector inside the prefab. Here’s what I have:

buildingText.js

#pragma strict

var dupeScript : buildTextInst;		// The script that contains the names and locations of the buildings.

private var cam : Camera;
private var build : GameObject;

function Start () {

	//dupeScript = gameObject.Find("Building Text Obj").GetComponent("buildTextInst");
	
	cam = dupeScript.displayCam;
	build = dupeScript.building;

}

function Update () {
	
	// Checks to make sure the chosen camera is enabled.
	if(cam.enabled == true){
		var screenPos : Vector3 = cam.WorldToScreenPoint (build.transform.position); // Translates the object's world position to screen position.
		guiText.pixelOffset = Vector2(screenPos.x,screenPos.y);
		guiText.text = build.name;	
	}
	else
		guiText.text = "";

}

buildTestInst.js

#pragma strict

var buildings : GameObject[]; 		// "Buildings" is the set of all buildings in the map
var building : GameObject;			// Used by the loop in Start() to get all of the buildings

var prefab : Transform;				// This is the object being duplicated

var displayCam : Camera;			// This is the camera that is being used.


function Start () {

	// Finds all of the Game Objects with the tag "Building" and inputs them into "buildings".
	buildings = GameObject.FindGameObjectsWithTag ("Building");
	
	// Runs through all of the buildings with the tag "Building".
	for (var building : GameObject in buildings)
		Instantiate(prefab,Vector3(0,0,0), Quaternion.identity);

}

function Update () {



}

for(var building : GameObject in buildings)
var clone : GameObject;
clone = Instantiate(prefab, Vector3(0,0,0), Quaternion.identity);
clone.transform.parent = building.transform;
clone.AddComponent(“buildingText”);

I apologize if my answer is a little wrong for the coding…I only use C# for Unity. I think I got what you were asking correct though…