using UnityEngine; public class CoinPortal : MonoBehaviour { public UnityEngine.UI.Text t1; public GameObject portal; public string text = "Coins: "; public static int count = 0; bool was = false; // does not work twice void OnTriggerEnter(Collider other) { if (other.tag == "Player" && was == false) { count++; if (count > 9) { portal.SetActive(true); } was = true; t1.text = text + count; Destroy(gameObject); } } }