Destroy() not working on prefab instance

I have some code that determines the movement path between two sets of coordinates contained within a script (TileMoverScript) that is itself a component of the TileMover gameobject. In order to access it, I instantiate an instance of TileMover, access a public method within TileMoverScript, and then destroy the instance of TileMover.

There’s just one problem: Destroy isn’t destroying the gameobject.

Here is my code:

        List<string> movesSeq = null;

        GameObject moveTileInstance = Instantiate( Resources.Load( "TileMover" ) , new Vector3( 0 , 0 , 0 ) , Quaternion.identity ) as GameObject;

        TileMoverScript tileScript = moveTileInstance.GetComponent<TileMoverScript>();
        tileScript.passData( battlefieldScript , unitData.uniqueID , destination[0] , destination[1] , unitData.coords , largerDimension , moveType , moveableSpots , moverArmy , 0 );
        bool foundpath = tileScript.findMovesSequence();

        if( foundpath == true ) {
                movesSeq = tileScript.movesSeq;
        }

        Destroy( moveTileInstance );

Any idea what the deal is here?

Try DestroyImmediate()

1- Don’t use DestroyImmediate. It will destroy the prefab itself from the game files, not the instance.

2- Try removing the “as GameObject” part. It’s the only think i could think of