Wont allow me to create more than 1 LineRenderer

I am attempting to create LineRenderers at runtime(when the user presses a button).

My Problem: I can never create more than one LineRenderer. When I go to created the 2nd one, the LineRenderer object is always NULL.

What am I doing wrong? Can you provide advice on what I need to do to create more than one LineRenderer?

public class AppInit : MonoBehaviour {
	public Vector3[] TEST_VERTICES;
	public const int SPEED = 5;
	public List<LineRenderer> lines;
	// Use this for initialization
	void Start () {
		TEST_VERTICES = new Vector3[10] {new Vector3(0,0,0), new Vector3(10,10,10), new Vector3(30,10,50), new Vector3(30,40,50), 
			                             new Vector3(10,30,90), new Vector3(10,20,40), new Vector3(50,20,40), new Vector3(70,80,90), 
			                             new Vector3(10,70,20), new Vector3(60,10,0)};
		lines = new List<LineRenderer>();
	// Update is called once per frame
	void Update () {
		float x = Input.GetAxis ("Horizontal") * Time.deltaTime * SPEED;
		float z = 0;
		float y = Input.GetAxis ("Vertical")   * Time.deltaTime * SPEED;
		gameObject.transform.Translate (new Vector3(x,y,z));
	void OnGUI() {
		if (GUI.Button (new Rect(10,10,100,20), "Create"))
	public bool createString( Vector3[] vertices ) {
		LineRenderer lRend = gameObject.AddComponent ("LineRenderer") as LineRenderer;
		//LineRenderer lRend = new LineRenderer();
		Debug.Log ("IS NULL"+(lRend == null).ToString ());
		lRend.SetColors (new Color(100,0,0,100), new Color(0,0,100,100));
		lRend.SetWidth(10, 1);
		for (int i=0; i<vertices.Length; i++)
			lRend.SetPosition(i, vertices*);*
  •   	return true;*
  •   }*
  • }*

It should be possible to attach more than one linerenderer to one gameobject, but in your case all are drawing exactly the same… You set the exact same vertices array. It depends on the LineRenderer-useWorldSpace setting if the positions are relative to the objects position, so if you move the gameobject the line moves along, or relative to the world. In both cases your multiple lines will be exactly the same…

What do you want to achieve? a TrailRenderer?

btw, there is a generic version of AddComponent:

LineRenderer lRend = gameObject.AddComponent<LineRenderer>();