How to deactivate an object in array which was chosen randomly before then activate randomly another one also in that array?

I don’t even know if my question makes any sense or not but i will try to explain it well.
The game is in 2D.
I’m having a box which is basically an array containing objects (objects are being childs of player and also being deactivated). Those boxes are being instantiated randomly in the scene after a random amount of time.


When player collides with a box, it will make the player activate randomly an object which is a child of the player. What i want to achieve is: when the player collides again with another box and if the currently active object is still there, i want to make the player deactivate the currently active object and activate randomly another one. And so on.


Right now i have come with the solution in the script below, but it 's kinda buggy and i know this isn’t the right way to do it. Sometimes it did the job, sometimes it activated 2 or more objects simultaneously.
So if anyone has better solution, please help. Thank you for reading my question. Here is the script:

public GameObject[] Objects;
    GameObject currentObject;
    GameObject newObject;
    int i;
    int j;
    private void Update()
    {
        i = Random.Range(0, Objects.Length);
        currentObject = Objects*;*

j = Random.Range(0, Objects.Length);
newObject = Objects[j];
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == “PickupAble”)
{
if(currentObject.activeInHierarchy==false)
{
currentObject.SetActive(true);
Destroy(collision.gameObject);
}
}
if(collision.gameObject.tag==“PickupAble”)
{
if(currentObject.activeInHierarchy==true)
{
currentObject.SetActive(false);
newObject.SetActive(true);
Destroy(collision.gameObject);
}
}
}

there is no reason to put things in update unless they have to repeat every frame!!!
this should be all you need

	public GameObject[] Objects;
    public int c = -1;

	private void OnCollisionEnter2D(Collision2D collision)
	{if (collision.gameObject.tag == "PickupAble")
		{  if(Objects.Length>1){
				int n = Random.Range(0, Objects.Length);
				//this line ensures you dont pick the same one from before
			while(c==n){n = Random.Range(0, Objects.Length); }
				Objects[n].SetActive(true);
				if(c>-1){Objects
.SetActive(false);}
    				Destroy(collision.gameObject);
    				c=n;
                    }else{print ("oops there is only one item"); }}}