I guess that your “hit” variable is a RaycastHit which should be related to a Physics.Raycast call. “hit” is only valid when Physics.Raycast returns true. Without the code around this line you posted we can’t say what’s wrong.
If it’s really this line i just guess that hit is not initialized and hit.transform is null. The tag of a gameobject usually can’t be null. If it has no tag it’s usually an empty string.