I believe you need to check something like this :
if (Physics.Raycast(ray, out hit))
{
if (hit.collider.name == "name)
{
I am not sure but thats all ive got
↧