How to create a straight line to collide in objects?

Hi! I’m trying to use the raycast but when striking the object appears this message:

Field ‘UnityEngine.RaycastHit.Collider’ not found.

The code:

var Range = 10;

function Update()
{
	var hit : RaycastHit;
	var fwd : Vector3 = transform.TransformDirection(Vector3.forward);
	
	Debug.DrawRay(transform.position, fwd, Color.green);
	
	if (Physics.Raycast(transform.position, fwd, hit, Range))
	{
		if (hit.Collider.gameObject == "tree")
		{
			Debug.Log("Ok");
		} 
	} 
	else
	{
		Debug.Log("No");
	}
}

Just a simple code that allowed me to show the log message when the camera get the object. But this error message doesn’t make it works correctly. What can be this error?

The name of the “collider” variable should be spelt with a lowercase letter C - the language is case-sensitive, so “collider” and “Collider” are treated as two different names.

Yes I can fit to run the file was this:

var Range = 10;

RayShoot function ()
{
var Hit: RaycastHit;
var = DirectionRay transform.TransformDirection (Vector3.forward);

Debug.DrawRay (transform.position, DirectionRay * Range, Color.Blue);

if (Physics.Raycast (transform.position, DirectionRay, Hit, Range))
{
if (Hit.rigidbody)
{
//action
}
}

}

Now, we only insert the elements you want, but the correct structure I’m using for this is that the raycast. Thanks!