So to change the material, you just need the index of the material from the array, and put that in the code.
When you want to remember what index ( material ) they were on, you need the save game. This is my save game 101, which coincidentally has an example with an integer:
