Help for acces variable in OnMouseDown event

I have a game where you in the main menu is possible to click on a cube and switch The player to a random Color.
I have made it with a OnMouseDown event, and its Working fine, except when you are going to the select level scene and back to the menu it’s just reset the color of the cube. I use a variable which get a random color to do it and I want to just when my menuback function is called set the variable to what it was before, but i don’t know how to do it.
Do you guys got any ideas?’

Hello there.

You need to learn to store information between scenes, which is a VERY IMPORTANT feature to develop a game.

You should take your time, watch this Unity tutorial and learn about “DontDestroyOnLoad()” method. It will allow you to “store” information when changing scenes.

Good luck!