Creating a light in game C#

I i’m trying to create a light when triggerenter, but the only thing I found was creating a game object with mesh or a prefab… but I dont want to make a prefab because I want the light to have a color assigned already in other script.
What I have now is a script that change a plane to random colors and I need to create a light with the same random color as the plane and placed at some distance over the plane transform.

You can create a light from scratch at runtime. You create a game object, position the game object, attach a Light component, then set the Light parameters. Exmaple:

#pragma strict

function Update() {

	if (Input.GetKeyDown(KeyCode.A)) {
		var go = new GameObject();
		go.transform.position = Vector3(0,5,0);
		var light = go.AddComponent(Light);
		light.color = Color.red;
	}
}

The default type for a new light is ‘Point’, but you can adjust that and other aspects of the Light component.

Note it would be easier to create a prefab of a light with all the setting you want. Then Instantiate() that prefab at the position you want and make any final light adjustments.