wait till the audio finish

Hello every one i always try to make an FPS Game but i always stuck on the same problem and it started making me so nervous please my question is :
How do i stop shooting till the reload sound end , Here is the reload function :

function Reload () {
AudioSource.PlayClipAtPoint(reloadsound, transform.position);
clips--;
bullets = maxbullets;
}

@mohaaaaamed

You could simply use the AudioSource.isPlaying boolean to evaluate whether or not the reload sound is still playing. Here’s a link to the API which shows an example:

AudioSource.isPlaying - Unity Scripting API

I hope this helps! :slight_smile:

thank’s but i already solved it on myself but now am having a really strange problem in my reload function i play an audio clip and it was working but when i added GetComponent.().Play(“Reload”); it doesn’t work it gives me such a strange sound when i reload but the animation work properly here is my reload function
function Reload(){
if(magsLeft > 0){
reloading = true;
GetComponent.().PlayOneShot(reloadSound);
GetComponent.().Play(“Reload”);
bulletsInMag = 60;
magsLeft = magsLeft-1;
yield WaitForSeconds(5.0);
reloading = false;
}
}