Sound Clip Heavy Distortion

Hey guys first post… still a newbie.
trying to call an audio clip to play when the player hits a certain collider, this instance a door to a certain building, door already has an animation on it. The sound clip itself is fine,but when i call it to be played, it seems like there is multiple instances of the clip, or it is being asked to play over and over? as its very loud and distoreted, so it seems like a coding error i guess??

im opening the doors using a raycast, so i have just asked the sound clip to be called when this raycast collides with “BuildingDoor”

function Update ()
{
var challengeAudio : AudioClip;
var hit:RaycastHit;

//Check for collison with var myRaycast
if (Physics.Raycast(transform.position, transform.forward, hit, myRaycast))

{
           if (hit.collider.gameObject.name == "IndustrialEntrance")
	{
		audio.PlayOneShot(challengeAudio);
		hit.collider.gameObject.animation.Play("interiorDoorSwing");
	}

}

but something has clearly gone wrong…

You could make a bool, like shouldSudioPlay and set it to true before you get to the door. If the bool is true let the audio play and then immediately set it to false. After the door is shut set it back to true in case you want to go back through the door and you need the audio to play again. Something like this:

        function Start ()
        {
            var audioShouldPlay = true;
        }
        function Update () 
        { 
             var challengeAudio : AudioClip;
             var hit:RaycastHit;
    
             //Check for collison with var myRaycast
             if (Physics.Raycast(transform.position, transform.forward, hit, myRaycast))
             {
                 if (hit.collider.gameObject.name == "IndustrialEntrance")
                 {
                    if (audioShouldPlay)
                    {
                        audioShouldPlay = false;
                        audio.PlayOneShot(challengeAudio);
                    }
                    hit.collider.gameObject.animation.Play("interiorDoorSwing");
                 }
             }
        }

Add a check to see if the audio is already being played so you don’t call it multiple times.

var challengeAudio : AudioClip; 
function Update () { 

    var hit:RaycastHit;

    //Check for collison with var myRaycast
    if (Physics.Raycast(transform.position, transform.forward, hit, myRaycast)) {
      if (!audio.isPlaying && hit.collider.gameObject.name == "IndustrialEntrance")
      {
        audio.PlayOneShot(challengeAudio);
        hit.collider.gameObject.animation.Play("interiorDoorSwing");
      }
}

You could do the same thing using a variable to check if the door is currently being opened and only if it is false play the sound.