Set Gameobject a certain color based off of other game objects

In my game I have 6 different colors. I also have 4 balls. These balls will have a random color attached to them. I also have a box at the bottom that will change to a certain color. The problem is that I can’t figure out how to make it so that the box is one of the colors that the balls have. Also, when a ball hits the box, the balls change to a random color again and the box has to change to one of the colors that the balls have at that moment. I don’t even know where to start.

watch this tutorial, it will give guide you. But to get what you want you’ll have to put some efforts. I am also new to this otherwise I would have helped you a little more.