Hi, I have problem with my script that is storing amount of currency (currency is dropped when enemy is killed). Method changeQuantity() is called from script attached to Player when enemy is killed and is incremented by one.
The problem is that it seems like the script is somehow “carrying” essenceQuantity from previous Play Mode. For example, when I enter Play Mode and kill one enemy, the essenceQuantity = 1. When I exit and enter Play Mode again, after killing one enemy, the essenceQuantity = 2 and so on.


Screens were taken in two Play Modes after killing one enemy.
public class Blood_Essence_Quantity_Script : MonoBehaviour
{
private int essenceQuantity;
void Awake()
{
essenceQuantity = 0;
Debug.Log("Quantity after Awake = " + essenceQuantity);
gameObject.GetComponent<Text>().text = essenceQuantity.ToString();
}
public void changeQuantity(int quantityDiference)
{
Debug.Log(quantityDiference);
essenceQuantity = essenceQuantity + quantityDiference;
Debug.Log("Quantity after killing enemy = " + essenceQuantity);
gameObject.GetComponent<Text>().text = essenceQuantity.ToString();
}
}