Respawn sound not working

Hello, I’m trying to write a respawn script but whenever it does, the lose sound isn’t playing.

        if (other.gameObject.CompareTag("respawn"))
        {
            source.clip = losesound;
            source.Play();
            Application.LoadLevel(Application.loadedLevelName);

        }

I also tried this, but my collectibles aren’t setting themselves to “true” and the count number doesn’t change.

        if (other.gameObject.CompareTag("respawn"))
        {
            source.clip = losesound;
            source.Play();
            other.gameObject.SetActive(true);
            transform.position = new Vector3(83, 11, -250);
            count = 1;

        }

For your sound issue, you’re playing the clip on line 4, and in the very next line, you’re loading a new scene. Application.LoadLevel does not wait for your sound to play through before doing it’s thing.

If you write this right after playing your sound, the program will wait a given number of seconds before going to the next line.

yield WaitForSeconds (1.15);

Just replace 1.15 with however many second your sound lasts, and make small adjustments if you want to it to wait longer.

If losesound is your AudioClip, you can just put losesound.length in the parentheses