Here you are changing the variable for all the objects. You need to use “static float Range(int min, int max)”. Use this code…
if (GUI.Button (new Rect (Screen.width * 0.2875f, Screen.height - 35, Screen.width * 0.2f, 20), "Change Class"))
{
GameObject Listing = GameObject.Find ("Troops");
SControler = (TroopsLists)Listing.GetComponent (typeof(TroopsLists));
//If trooper is array then use "trooper.Length" if that is List then use "trooper.Count" in the following line.
int iIndex = Random.Range(0 , SControler.troopers.Length);
Troopcontroler = (Troopclassecontroller)SControler.troopers[iIndex].GetComponent (typeof(Troopclassecontroller));
Troopcontroler.actualclass = 1;
Troopcontroler.classdetermination ();
}