Instantiate GUIText object and add script to it?

I'm wondering if I can instantiate a GUIText within a script and subsequently attach a script to it? Easy enough to do in the inspector, but in a script I get an error when trying to attach a script to the GUIText.

Seems pretty simple, but not sure how to implement it.

Basically, I've got a bunch of objects and a script I would like have slap a GUIText onto each gameobject, along with a behavior script for each GUIText.


n = new GameObject("bla");
n.guiText.text = "blabla";

also, u can make an array and add to every gameobject GUIText component..

var urGameObjects: GUIText[];
for(i = 0; i < urGameObjects.Length; i++)
urGameObjects *= n.AddComponent("GUIText");*