How do I destroy a spawned object

My code creates an sphere object after 10 seconds and then its supposed to destroy it after 20 seconds. I see it being spawned after 10 seconds but it just keeps creating Sphere(clones) after 20 seconds. I was hoping that it would spawn after 10 secs and then destroy it after 10 secs and keep repeating the cycle.

Here is the code:

using UnityEngine;
using System.Collections;

public class Spawn_Sphere : MonoBehaviour {

public GameObject Sphere;
public float timer = 0.0f;
public int spawned = 0;

void SpawnIt(){
	//Vector3 position = new Vector3(Random.Range(-10.0F, 10.0F), 0, Random.Range(-10.0F, 10.0F));
	Vector3 position = new Vector3(350,10,283);
	Instantiate(Sphere, position, Quaternion.identity);
	spawned = 1;

// Use this for initialization
void Start () {


// Update is called once per frame
void Update () {

	timer += Time.deltaTime;
	if (timer > 10 && spawned == 0) {


	if (timer > 20 ) {

		timer = 0.0f;
		spawned = 0;



You are destroying your prefab, not the object you spawned. In order to do things the way you have here, you’d need to save a reference to the spawned object. As an alternate, you can use the form of Destory() that allows you to specify a future time. So line 8 would get replaced by:

 GameObject go = Instantiate(Sphere, position, Quaternion.identity) as GameObject;
 Destory(go, 20.0f);

This will cause the just created object to be destroyed in 20 seconds.