NullReferenceException: Object reference not set to an instance of an object RayCastTree.Update () (at Assets/Scripts/RayCastTree.js:19)

I tried everything to fix this, but i cant, pls help me:
#pragma strict

var rayLength = 10;

private var treeScript : TreeController;

private var playerAnim : PlayerControl;

function Update()
var hit : RaycastHit;
var fwd = transform.TransformDirection(Vector3.forward);

if(Physics.Raycast(transform.position, fwd, hit, rayLength))
	if(hit.collider.gameObject.tag == "Tree")
		treeScript = GameObject.Find(;
		playerAnim = GameObject.Find("FPSArms_Axe@Idle").GetComponent(PlayerControl);
		if(Input.GetButtonDown("Fire1") && playerAnim.canSwing == true)
			treeScript.treeHealth -= 1;


The third parameter in Physics.Raycast, hit, is supposed to be the parameter u pass to know how far you want your ray to be cast along the plane.

Instead of Physics.Raycast(transform.position,fwd,*hit*,*rayLength*),

You should try


which properly sets the rayLength and layermask hit parameters.

Assets/Scripts/RayCastTree.js(12,27): BCE0023: No appropriate version of ‘UnityEngine.Physics.Raycast’ for the argument list ‘(UnityEngine.Vector3, UnityEngine.Vector3, int, UnityEngine.RaycastHit)’ was found.