How to make a game object pop out of another game object ?

I want to make coins pop out of a box object when the player destroys it , and i want them to pop out in random directions with a certain speed and drop on the ground for the player to pick them up (all this in 2d). Any idea how to do that?

hello, you can do something like this

void OnBlockDestroyed()
{
    Instantiate(coinPrefab, blockTransform).GetComponent<Rigidbody2D>().AddForce(new Vector2(Random.Range(-0.5f, 0.5f), 1) * forceMultiplier);
}

cointprefab is a prefab of your coin, blocktransform is the block you are destroying make sure the coin prefab has a rigidbody2d and just change the forcemultiplier for adding more force to the coin