internal void SetAttackTarget(GameObject gameObject) { if (NumberOfSelectedUnits() != 0) { GameObject[] units = GameObject.FindGameObjectsWithTag("Units"); foreach (var s in SelectedUnits) { foreach (var o in units) { UnitScript u = o.GetComponent <UnitScript>(); if (u.Name == s) { u.SetAttackTarget(gameObject); } } } } }