How to use a raycast to interact with an object?

I wrote a script to make a raycast from the player and if it hits a weapon that I have on the wall I can press q and it will deduct one Level Point and make my damage go up. But I can’t seem to get it to work.

function Update(){
    if (Input.GetButtonDown("Fire1")){
    Shoot();
    }
    if(Input.GetKeyUp("q"))
{
	print("You pressed q");
		if(Physics.Raycast(transform.position,transform.forward,hit,5))
		{
		print("The Raycast is working");
			if (hit.collider.gameObject.CompareTag("Weapon Upgrade"))
			{
			print("It knows that the weapon is a Weapon Upgrade");
				if (Score.levelPoints > 0)
				{
				print("It is applying the upgrade.");
				Score.levelPoints -=1;
				playerDamage += 50;
				}
			}
		}
}

It prints you pressed q and the raycast is working but it doesn’t print any farther than that even when I am looking directly at the gun and am really close to it. I would also like to be able to print out a message on the screen to tell the player that they can press q to upgrade it.

Never mind I figured it out. It needed a box collider. Thank you guys very much.