Why Does My GameObject Not Spawn Anymore?

Why does my gameobject not spawn if I don’t grab it? The other gameobjects spawn just fine even after not grabbing it, but not this certain one. The gameobjects are all constantly spawning, except the one that doesn’t respawn after not grabbing it because it’s supposed to spawn only after I collect 10 of a different gameobject(I hope you understood that). So what could be the problem? Here’s my GameObject script(this script spawns both the gameobjects I need to collect and the one that doesn’t respawn): http://pastebin.com/RuU9UrDj

Now I have a pretty good feeling that it’s defiantly the script that I posted that’s the problem. I tested it with a different spawn script and the gameobject respawn/kept spawning even after not grabbing it. I know this is pretty a vague explanation and question, so I’m sorry. Anyways I hope someone can help me see what’s the problem here.

At a glance, you need to pick up a “Coin” before spawned = false; If you havent done this the instantiation is not invoked. Not sure if Im just describing your intended behaviour here.

But this:

&& timer == 0

Could be a problem too. How about:

&& timer <= 0.0f

Your problem is, that you destroy the parent game object and with it your whole script. So after u have destroyed it, the script doesnt exist anymore. You should just make a parent gameobject with the destroyer script and let the to be destroyed items spawn as children into it. Than call the destroy function for children and not for the parent. Should solve your problem