Not finding object with raycast?

So I’m not sure why but I’m not getting the gameobject of a raycast that is being cast on it.

if (Input.GetButtonDown("Fire1"))
{
   RaycastHit hit;
   Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
   if (Physics.Raycast(ray, out hit))
   {
      Debug.Log(hit.transform.gameObject);
   }
}

I’ve been adding debugs everywhere and I know its all working properly, except the final if statement. Any idea why?

Does the GameObject have a collider?

It should, if not does it have to have one?

Can I get an object without a collider or is that required?

It has to have one. In fact, colliders are the only thing Physics.Raycast can hit.