Disable all gameobjects from a prefab

In the game I’m making, I want to disable all gameobjects from a specific prefab in the script, so that all coins disappear. Is there a way to do this?

This is the first 2D videogame I’m making so I don’t know much about this.

Thanks a lot! Any help is really appreciated!

try putting a tag on the prefab,
and then call this line in your code

        foreach (GameObject x in GameObject.FindGameObjectsWithTag("Coin"))
        {
            x.SetActive(false);

        }  

hope that helps.

you can use OnCollisionEnter function if you want something (like player) will collide with the coin and coin will be disappear

void OnCollisionEnter2D(Collision2D col)
{
        if( col.gameObject.tag == "Coin" )
        {
             Destroy(col.gameObject);
        }
}