Changing and getting the terrain's colours

Hello. I am looking to save the workspace’s terrain colours in a table, then set the terrain colours to something else, and then put it back to the original colours. Is this possible? I’ve tried changing and saving material colours and a script and I wasn’t able to. Any help is appreciated!

Never mind, found it out myself.