MissingReferenceException error.

Hello. I got most of the things from my first question (here) to work but I have a new problem. As the title says I get that error when I successfully destroy a meteor. The guiText attached to it however doesn’t get destroyed with it and I get the error “: The object of type ‘Transform’ has been destroyed but you are still trying to access it.” Double clicking brings up ObjectLable.js to the line:

 thisTransform.position = cam.WorldToViewportPoint(target.position + offset);

I’ve tried adding Destroy commands to the collision script, even tried adding:

if(target == null)
{
   Destroy(this);
}

After that previous line of code. I’ve tried remaking my meteorPrefab with textPrefab as a sub-component with no better results.

Thanks in advance for assistance.

When you say :

if(target == null)
{
   Destroy(this);
}

Your telling unity to destroy the script. If you want to destroy the entire gameobject use:

if(target == null)
{
   Destroy(gameObject);
}