You are declaring the counter variable in the Update loop. Try moving the int counter = 0; out of the Update(). Also, counter = counter++ is unnecessary, just counter++ is enough.
public class ExampleClass : MonoBehaviour
{
int counter = 0;
void Update()
{
if (counter <= 0)
{
counter++;
//Debug.Log(counter);
}
if (counter == 200)
{
Destroy(gameObject);
}
}
}
Another way to do this is using an overload of the Destroy() method.
public class TimedDestroy : MonoBehaviour
{
public float timeBeforeDestroy = 10f; // 10 Seconds
public void Start()
{
Destroy(gameObject, timeBeforeDestroy);
}
}