i already have it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class coins : MonoBehaviour
{
public int coinsCollected;
public Text counterText;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if (other.tag.Equals("Coins"))
{
coinsCollected++;
other.gameObject.SetActive(false);
counterText.text = coinsCollected.ToString();
}
}
}