how do I attach a player with a navMeshAgent

C#
 public var player : Transform;    function Awake () { player = GameObject.FindGameObjectWithTag ("Player").transform; nav = GetComponent (UnityEngine.AI.NavMeshAgent); }  function Update() {     var distance = Vector3.Distance(player.position, transform.position);              if(distance <= 30) {                        nav.enabled = true;            nav.SetDestination (player.position);         }                 else  {            this.nav.enabled = false;                  } }
Source

Also in C#: