How do you delete and respawn an object

I’ve had this idea for a puzzle game and right now I’m trying to make it to when I step on a button a cube spawns. The issue though is I want that every time i step on the button the cube respawns. kinda like the cubes in the portal games.

the script that I’m using:

bool hasSpawned = false;
public GameObject Box;
public GameObject boxSpawner;

void OnTriggerEnter(Collider other)
{
    if (!hasSpawned)
    {
        hasSpawned = true;
        Instantiate(Box, boxSpawner.transform);
    }

    if (hasSpawned)
    {
        Destroy(Box);
        Instantiate(Box, boxSpawner.transform);
    }

}

}

Hello.

You are not using correctly the OnTriggerEnter() you need to specifu which collider you want to collide with. It can not be explaied here, is something you need to learn first,.

I strongly recommend to watch some tutorial in your language about TRIGGERS AND COLLIDERS

God luck!!