The obstacle are generated using a generate script and gameobject is in the prefabs folder i have attached the gameobject with the generate script the problem is that it wont get destroyed
using UnityEngine;
using System.Collections;
public class Generate : MonoBehaviour
{
public GameObject rocks;
int scr;
The reason why its not destroying is because you are trying to destroy the original prefab. You cant destroy prefabs as its not safe to do so, in case of data loss, since its not in the scene. To destroy clones, you need to find the clone objects, either by searching for all the gameobjects called rocks(Clone) and destroying those, or you can tag all generated clones right after theyre instantiated and destroy all objects with that tag. This is just for anyone else who needs a solution for this question as the asker probably wont see it.