using UnityEngine; public class CoinProSound : MonoBehaviour { public TMPro.TextMeshProUGUI t1; public string text = "Coins: "; public AudioSource music; public static int count = 0; bool was = false; // doesn't work twice void OnTriggerEnter(Collider other) { if (other.tag == "Player" && was == false) { count++; was = true; t1.text = text + count; music.Play(); Destroy(gameObject); } } }