Problem with Raycast

Good afternoon, all right? I am using a script with raycast to detect when the player clicks the “Box” at a certain distance, but I’m in trouble. My code is below:

#pragma strict
public var boxes = 0;
public var textoConsole : GameObject;

function Start () {
	
}

function Update () {
	var raycastFrente = transform.TransformDirection(Vector3.forward);
	var objetoAcionado : RaycastHit;
	
	Debug.DrawRay(transform.position, raycastFrente, Color.green);
	
	if(Input.GetButtonDown("Fire1"))
	{
		if(Physics.Raycast(transform.position, raycastFrente, objetoAcionado, 2.5))
		{
			if(objetoAcionado.collider.tag == "Box")
			{
				print("You clicked on the box!");
			
				boxes = boxes + 1;
			}
		}
	}
}

But this way, the script is not triggered when any part of the object… I believe it is because of RayCast not reach certain parts… For example, I have a box and when I’m at a certain distance of it, it becomes selectable. If I click on the top of the box, it triggers the script, but if I click on the side, it does not trigger. Any idea? Thank you!

Try using

transform.forward;

Instead of

transform.TransformDirection(Vector3.forward);