if distance is more then maxdistance don't cast hit

Info : as soon as i go up to it, it starts constantly woodcutting, it has a 10 second delay with the debug.log message & xp update, apart from that the Title says it all, any help would be appreciated, Thanks!
here’s a part of the script that contains the raycast it goes on the tree.

unction Update ()
{
	if(Input.GetKeyUp(KeyCode.Backspace))
	var hit : RaycastHit;
	var ray = Camera.main.ScreenPointToRay(Vector3(Screen.width/2, Screen.height/2, 0));
	if (Physics.Raycast (ray, hit))
	{
		ChopDistance = hit.distance ;
		if (ChopDistance < ChopMaxDistance)
		{
		    inputText.enabled = true;
            inputText.text = "Press backspace to woodcut";
			hit.transform.SendMessage("Woodcutting", xp, SendMessageOptions.DontRequireReceiver);

Physics Raycast is an overloaded parameter, pass in the distance you want it to be checked.

if (Physics.Raycast (ray, hit))

above code makes a Ray, of infinite length. You can use Debug.Drawline, to see how far the ray is going.

if(Input.GetKeyUp(KeyCode.Backspace))
{    var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay(Vector3(Screen.width/2, Screen.height/2, 0));

}
// Stop the Raycasting of the last ChopDistance;if it is more than Max

if (ChopDistance < ChopMaxDistance)
{ 
// Add Max ChopDistance not Infinite
if (Physics.Raycast (ray, hit, ChopMaxDistance))
    {
       ChopDistance = hit.distance ;
           inputText.enabled = true;
            inputText.text = "Press backspace to woodcut";
         hit.transform.SendMessage("Woodcutting", xp, SendMessageOptions.DontRequireReceiver);

Cant test cause the code is not complete, but in general, you wouldn’t want an infinite raycast length, start with 5 or 10 and see how much distance you want. 5 or 10 is the ChopMaxDistance.