Select instantiated object with mouse

Hello,

Im having some problems with this script im working on to select an object, im getting an error saying: unknown identifier:‘color’. and ‘changeColorRed’ is not a member of ‘unityEngine.Transform’.

Im a started at scripting, so i belive maybe i am putting something in the wrong order that maybe could be the problem.

heres the script:

var selecaoMouse : Transform;

var ray : Ray = camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;

Debug.DrawRay (ray.origin, ray.direction * 100, Color.yellow);

function changeColorRed()

{
selecaoMouse.renderer.material.color = color.red;

}

if (Physics.Raycast (ray.origin, ray.direction, hit, 100))

{

if(hit.collider.tag == "Object")
{

	var object : GameObject = hit.collider.gameObject;
	if(object != selecaoMouse) //new object selected
	{
	
		selecaoMouse.changeColorRed(); //unselect object
		selecaoMouse = object;
	}

}

}

im trying to figure out which is the problem with this script, i saw many examples of similar ones here on unity answers, but for some reason i couldnt make this work, i would appreciate some help on the subject

thanks for the attention

Vinicius Girotto

Thanks for the support, and indeed i dont know how to program in JavaScript, i mean, i am learning the syntax and the concepts while doing this project.
There are some programming concepts that are still a bit cloudy to me yet, anyway thanks for the attention, i managed to make it work after yout tips, and ill keep on with the studies now.