[Solved]Playing two sound files from one object

Hello, I am quite new to Unity and doing small project for school and I am quite stuck. What I need is to play two sound files after I click button. One is casting effect and other is spell effect sound which will play 1.5s after pressing button. Problem with my script is that it only plays first AudioClip but not second. Unity is throwing me error IndexOutOfRangeException: Array index is out of range. for lines 15 and 32 (audios[1].clip = clips[1]; and audios[1].PlayOneShot (clips[1]));. Can anyone help me?

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

[RequireComponent(typeof(AudioSource))]

public class Heal : MonoBehaviour {

    public AudioClip[] clips;
    private AudioSource[] audios;

    void Start () {
        audios = GetComponents<AudioSource> ();
        audios[0].clip = clips[0];
        audios[1].clip = clips[1];
       
    }
    void Update() {
        if (Input.GetKeyDown (KeyCode.W)) {
            StartCoroutine (WaterEffect());
        }
    }

    public void WaterEffectClick() {
        StartCoroutine (WaterEffect());
    }

    public IEnumerator WaterEffect() {
        audios[0].PlayOneShot (clips[0]);
        yield return new WaitForSeconds(1.5f);
        audios[0].Stop ();
        audios[1].PlayOneShot (clips[1]);
    }
}

you don’t need two AudioSources. you just need to swap out the clip after the first clip is done playing or after 1.5 sec

try this. I free handed the code. sorry if there is a typo.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[RequireComponent(typeof(AudioSource))]
public class Heal : MonoBehaviour {
    public AudioClip[] clips;
    private AudioSource audios;

    void Start () {
        audios = GetComponent<AudioSource> ();
        audios.clip = clips[0];
    }
    void Update() {
        if (Input.GetKeyDown (KeyCode.W)) {
            StartCoroutine (WaterEffect());
        }
    }
    public void WaterEffectClick() {
        StartCoroutine (WaterEffect());
    }
    public IEnumerator WaterEffect() {
        audios.PlayOneShot (clips[0]);
        yield return new WaitForSeconds(1.5f);
        audios.Stop ();
        //audios.clip = clips[1];
        audios.PlayOneShot (clips[1]);
    }
}

just in case you wanted to play both at the same time, and then stop clip1 after 1.5 sec. here is the code

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

[RequireComponent(typeof(AudioSource))]
public class Heal : MonoBehaviour
{

    public AudioClip[] clips;
    private AudioSource[] audios;

    void Start()
    {
        audios = GetComponents<AudioSource>();
        audios[0].clip = clips[0];
        audios[1].clip = clips[1];
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.W))
        {
            StartCoroutine(WaterEffect());
        }
    }

    public void WaterEffectClick()
    {
        StartCoroutine(WaterEffect());
    }

    public IEnumerator WaterEffect()
    {
        audios[0].PlayOneShot(clips[0]);
        audios[1].PlayOneShot(clips[1]);
        yield return new WaitForSeconds(1.5f);
        audios[0].Stop();
       
    }
}

Works like a charm! Thank you very much.