Hi, so I’m making a game, and I want to make these collectables that give points and then disappear. I tried making a script like this, and it disappears, but doesn’t give the point. Could someone please help me?
public class Points : MonoBehaviour
{
public TMP_Text MyText;
private int score;
// Use this for initialization
void Start()
{
MyText.text = "";
}
// Update is called once per frame
void Update()
{
MyText.text = "" + score;
}
void OnTriggerEnter(Collider other)
{
score = score + 1;
Destroy(gameObject);
}
}