// Destroy ourselves
Destroy(gameObject);
if (Sparkles)
{
Instantiate(Sparkles, transform.position,transform.rotation);
}
if (Coin)
{
Instantiate(Coin, transform.position,transform.rotation);
}
It looks like you are instantiating the coin after you have destroyed the object that is spawning it, you mind find it can either no longer spawn the coin because the script has been deleted along with the gameobject, or that it can't get the game objects position/rotation for the same reason.
I could be wrong of course, I have a feeling it would throw an exception if this was the problem.
↧