using UnityEngine; using TMPro; public class Scorer : MonoBehaviour { [SerializeField] TextMeshProUGUI scoreText; [SerializeField] int maxHits; int hits = 0; void Start() { hits = 0; scoreText.text = "Hits: " + hits.ToString(); } private void OnCollisionEnter(Collision other) { if (other.gameObject.tag != "Hit") { if (hits < maxHits) { hits++; scoreText.text = "Hits: " + hits.ToString(); } else { gameObject.SetActive(false); } } } }