Audio play problem on raycast hit colider.gameObject.tag

This is the part of my script.

if(hit.collider.gameObject.tag == "Enamy")
{
lineRenderer.SetColors(color3, color4);
 
  if (!hit.collider.audio.isPlaying) hit.collider.audio.Play();
       
}

Basicaly I want raycast to hit the gameobject in the scene and play sound when it hits colider tag “Enamy”

the AudioSource is atached to the gameobject.

I want it to be continous sound but I have a problem…

When I move the camera away and raycast is not hiting gameobject that is tagged anymore sound keeps playing ,so how do I play the audio only when ray is hiting gameobject that is tagged?

Nevermind problem solved.