Audio for gun shot

Hi guys I was wondering if you could help me out with something. I made a script for my gun to shoot and I tried putting in an audio code and it doesn’t seem to work. Here is the code.

using UnityEngine;
using System.Collections;

public class Shoot : MonoBehaviour {

public GameObject bullet;
public float delaytime = 8;

private float counter = 0;
void Start ()
{

}

// Update is called once per frame
void FixedUpdate ()
{
if (Input.GetKey (KeyCode.Mouse0) && counter > delaytime)
{
Instantiate (bullet, transform.position, transform.rotation);
audio.GetComponent.Play (hit_power_fist);
counter = 0;
}
counter += 1 * Time.deltaTime;
}
}

Thanks to anyone that can help :slight_smile:

Is there an audiosource attached to the object where you attached this script to? Where did you declare the hit_power_fist variable? What errors (if any) do you get? If you want to play a oneshot of a clip try using PlayOneShot with a audioclip as parameter, the Play method only plays a clip if you’ve set the AudioSource.clip variable.