Im making a 2d platformer and i Just added a coin system but everytime my player goes to the next level the coin count starts counting up by two instead of one and the coin count restarts Im not sure why and I need help
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class CoinPicker : MonoBehaviour
{
private int Coins = 0;
public TextMeshProUGUI textcoins;
private void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.CompareTag("Coins")) {
Coins = Coins + 1;
textcoins.text = Coins.ToString();
Destroy(other.gameObject);
}
}
}