Hello so im using the GameObject.FindGameObjectsWithTag and whenever i run the game it wont destroy my prefabs when i try to destroy them, And i even applied the tag on the gameobject whats going On?
function Erase() {
if (HitBlock())
Destroy(hit.transform.GameObject.FindGameObjectsWithTag("Block"));
Yeah, that’s not how you use Destroy. This will destroy the array returned by FindWithTag, not the actual objects contained inside it!
Also, you are using
hit.transform.GameObject
there is no such member in transform. If you are trying to find only those gameObjects that are children of that transform, you need to check the individual members returned by the class function FindGameObjectsWithTag.
Of course, this assumes that hit is a valid variable, and has a member called ‘transform’ that is a Transform. Make sure you’re doing all of that, too.