You're not doing a null check at Line 8174: var e = hit.GetEntity();

it causes an NRE when the Raycast Hits something that isnt an entity as its trying to check the Prefab name of the entity without null checking it.

this seems to be a relatively rare issue thanks to the layer mask, but it did happen within a custom prefab for us so its possible that it can happen to other people/in other situations

ok added null check