RaycastHit: What is the difference between hit.transform.tag and hit.collider.tag and which should I use when?

I am trying to make the player shoot a raycast and detect if hit the enemy’s sphere collider. What should I use and which would work better? The objects both have tags on them.

I’m pretty certain that both do the same thing, it’s just that one accesses the tag via the transform and the other via the collider. As far as I know, there is no difference between them, except that one of them (if I had to guess, hit.transform.tag) might take minimally longer to do.

But you should be fine doing either.