void OnTriggerEnter(Collider enteredCollider) { if (enteredCollider.CompareTag("KillZone")) { if (this.tag == "Red") { QPlayer r = this.GetComponent <QPlayer>(); RedTeam rt = (RedTeam)r.team; rt.AddPlayer(); } else if (this.tag == "Green") { QPlayer g = this.GetComponent <QPlayer>(); GreenTeam gt = (GreenTeam)g.team; gt.AddPlayer(); } Destroy(gameObject); } }