Getting Object name with Raycast :?

Hello, is there a way to get the name of the object with a raycast hit and put it into a string variable???

and i need it not to be specific so not testing for the name before thanks.

 var hit : RaycastHit;


function rayCastDetection(){
	
		var fwd = transform.TransformDirection (Vector3.forward);
		if (Physics.Raycast (transform.position, fwd, hitDis)) {

		}
	
	}
	
	


}

Use this raycast function instead.

static bool Raycast(Vector3 origin, Vector3 direction, RaycastHit hitInfo, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers);

your RaycastHit will contain the transform which will get you to .gameObject.name

that makes no sense to me lol

       var hit: RaycastHit;
      var direction= transform.TransformDirection (Vector3.forward);
        if (Physics.Raycast(transform.position,direction, hit)){
           Debug.Log(hit.transform.gameObject.name)
        
    }

Something like this.