get color of randomly generated objects

I’ve got many platform for whom there are 3 colors which are generated automatically, I’d like that after game starts and they all get their random color (red,green or blue) it will return all the colors of the platforms and in my main script using a trigger my ball can determine which color the platform he is going to collide with, if the ball isn’t the same color of the platform - he will DIE

using UnityEngine;
using System.Collections;
using System;

public class test : MonoBehaviour 
{
	 
 void OnTriggerEnter(Collider other) 
    {
		if(other.transform.renderer.material.color==this.transform.renderer.material.color)
		{
			print(" keep roooling");
		}
		else
		{
			print(" die  ");
		}


		 
		 
	}
}