Destroy by tag not removing prefab

Hi. I want to destroy a prefab and get rid of it totally. Here’s my code:

        Debug.Log(GameObject.FindGameObjectsWithTag("tile").Length);
        Destroy(GameObject.FindGameObjectsWithTag("tile")[0]);
        Debug.Log(GameObject.FindGameObjectsWithTag("tile").Length);
        Destroy(GameObject.FindGameObjectsWithTag("tile")[0]);
        Debug.Log(GameObject.FindGameObjectsWithTag("tile").Length);

The console prints ‘7’ 3 times(the length), it does not make any sense hence I destroyed an object and I’m getting a fresh list with method FindGameObjectsWithTag… It dissapears from scene but still remains out there. Any ideas how to remove it for good?

It should remove at the end of the frame.

Many game engines internally use Destroy to really mean “Destroy at the end of the frame”. This is to reduce issues arising from objects becoming invalid mid frame, which is a common cause of bugs in games.

If you really want something to disappear straight away, DestroyImmediate is what you want. But really that’s unusual (other than in editor code) and you should stick with Destroy whenever possible.

Okay this is just a idea, and my comments aren’t working at the moment but im all for letting you know the quickest answer.

Okay say the object is named “Jimmy”
And the tag is “Jim”

Now, say you have 9 Jimmy’s and you want to keep one,
With all of them that you want to delete,

Rename it to something like ‘JimmyClone’
Then, instead of GameObject.Find, do Name.Contains, I don’t know off the bat because I’m not at home when writing this, but this can atleast help you get started for what you may wanna look for I don’t do well with this type of stuff so I’m sorry in advance.

First, you may need to declare a Array of GameObjects
So
public GameObject nameHere;

Then give it values
void Awake ()
{
nameHere = GameObject.FindGameObjectsWithTag (“Jim”);
}

Then whenever you want it to delete, for this I’m just gonna do it on a void AAA but it’s up to you.

public void AAA()
{
if (nameHere.name.Contains(“Clone”))
{
//code here
}
}