I am new to Unity 3d, and am having a problem with the renderer component not saving during Play mode.
While I am in Edit mode the prefab that I want to render shows up in the inspector. When I enter Play mode the renderer component gets removed from the scrip. When I go back to Edit mode the renderer gets added back. (In Play mode, if I move the prefab to the public renderer then, my script does what I want it to.)

I want the inspector to stop forgetting what renderer to use.
what am I doing wrong here?
{
public GameObject RoadPrefab;
GameObject RoadPrefabClone;
public Material[] MyMaterials;
public Renderer roadPrefabsRend;
private int index = -1;
void Start(){
roadPrefabsRend = GetComponentInChildren<Renderer>();
roadPrefabsRend.enabled = true;
}
void Update() {
RoadPrefabClone = Instantiate(RoadPrefab, transform.position, Quaternion.identity) as GameObject;
roadPrefabsRend.material = MyMaterials [index=Random.Range (0,3)];
RoadPrefabClone.transform.localScale += new Vector3(Random.Range (3, 11), 0.25f, 3);
Destroy(RoadPrefabClone, 10);
}
Thanks iwaldrop! I used changed the start function and it works now.
– zachwuzhere