public void changediff() { var Diff = GameObject.FindGameObjectsWithTag("Difint"); foreach (GameObject dif in Diff) { if (dif.GetComponent <DONTDESTRORYSP> ().difpage == pagechanged) { dif.transform.gameObject.tag = "DifSet"; difficulty.text = GameObject.FindGameObjectWithTag("DifSet").name; dif.transform.gameObject.tag = "Difint"; Debug.Log("Difficulty has been changed"); } else { } } var Illus = GameObject.FindGameObjectsWithTag("Illustrator"); foreach (GameObject Il in Illus) { if (Il.GetComponent <DONTILLUSTRATOR> ().difpage == pagechanged) { Il.transform.gameObject.tag = "Illustratorset"; Illustrator.text = "Illustrator: " + GameObject.FindGameObjectWithTag("Illustratorset").GetComponent <Text>().text; Il.transform.gameObject.tag = "Illustrator"; notfound = false; break; } else { notfound = true; } } if (notfound == true) { Illustrator.text = "Illustrator: Unknown"; notfound = false; } var chartus = GameObject.FindGameObjectsWithTag("Charter"); foreach (GameObject ch in chartus) { if (ch.GetComponent <DONTCHARTER> ().difpage == pagechanged) { ch.transform.gameObject.tag = "Charterset"; Charter.text = "Charter: " + GameObject.FindGameObjectWithTag("Charterset").GetComponent <Text>().text; ch.transform.gameObject.tag = "Charter"; notfoundd = false; break; } else { notfoundd = true; } } if (notfoundd == true) { Charter.text = "Charter: Unknown"; notfoundd = false; } }