public void ShuffleTeams() { _shuffleIcon.Show(); //shuffle the list to a random order. List <PlayerData> ActivePlayerList = PlayersData.FindAll(item => item.Player.activeSelf); PlayersData.Clear(); for (int i = 0; i < ActivePlayerList.Count; i++) { PlayerData temp = ActivePlayerList[i]; int RandomIndex = Random.Range(0, ActivePlayerList.Count); ActivePlayerList[i] = ActivePlayerList[RandomIndex]; ActivePlayerList[RandomIndex] = temp; } //loop through the list, destroying the players and creating the anew. foreach (PlayerData data in ActivePlayerList) { //save reusable data. data.Player.GetComponent <PlayerController>().Resurrect(); int playerNumber = data.PlayerID; Vector3 position = data.Player.transform.position; //KILL. DIE. Destroy(data.Player); PlayersData.Remove(data); //create a new player. PlayerCreationData createData = new PlayerCreationData { playerID = playerNumber, Position = position }; createPlayer(createData); } }