Apply changes to a random child from sublist

Hi, ALL!!!

I have a script that generates 8 objects (prefabs) and place them in 8 (of 12) random slots in the scene, in the way that the objects become the children of the slots. Further I need to apply changes to the children objects, but choosing randomly 1 object from the list of objects that are placed along a certain wall. I have a script to make it. But I don’t know why, instead of just 1 object that has to change, all the objects along the wall perform changes. Does someone have any idea where is a mistake here???

Thank you!

Code:

GameObject[] children = new GameObject[Wall1.Length];
    int count = 0;

    foreach (GameObject childSlot in Wall1) {

          if (childSlot.transform.childCount > 0) {                                                 
            Transform t = childSlot.GetComponentsInChildren<Transform> () [1];
            children [count] = t.gameObject;
            count++;

            int changeFunction = UnityEngine.Random.Range (1, 7);
            int randomObjectIndex = UnityEngine.Random.Range (0, count - 1);
            Changes (changeFunction, children [randomObjectIndex]); 
            }
     }

With the foreach you move across all the items in the wall. Under that loop, you apply once a random change, and that random change is applied as many times as items you have in the wall.

Solution? Move this lines outside the foreach:

int changeFunction = UnityEngine.Random.Range (1, 7);
int randomObjectIndex = UnityEngine.Random.Range (0, count - 1);
Changes (changeFunction, children [randomObjectIndex]);

THAT´S RIGHT!!! THANK YOU GUYS!