Cannot implicitly convert type UnityEngine.AudioClip[] to UnityEngine.AudioClip[]

**Hi im making a quiz game and i would like to put audioclip or audiosource on each question so ive decided to make a array of audio source in in the question data script and call it in the gamecontroller script. but theres an error cannot implicitly convert in the line questionAudio = questionData.questionAudio,

//array in my questiondata script
public class QuestionData
    public string questionText;
    public AnswerData[] answers;
    public AudioClip[] questionAudio;

//call in the gamecontrollerscript

private AudioSource Audiosource;

    private float timeBetweenQuestions;

 IEnumerator TimeBetweenQuestions()
    yield return new WaitForSeconds(timeBetweenQuestions);

    timeRemaining = 10;
    QuestionData questionData = questionPool[questionIndex];
    Audiosource.clip = questionData.questionAudio; //error in this line


I see you edited your question, but the code you’re showing can’t produce the error you mentioned. You should get an error like this:

Cannot implicitly convert type
UnityEngine.AudioClip to

There’s a huge difference. The “questionAudio” variable is of type AudioClip[] so it’s an array of AudioClips. However the [“clip” property][1] of the AudioSource component represents a single AudioClip. Of course you can not assign an array of AudioClips to a single AudioClip variable / property. You have to take one of the clips inside your array. So the easiest fix is this:

Audiosource.clip = questionData.questionAudio[0]; // grab the first element in the array

However this code could break when the array is empty since in this case there is no first element. So to be on the safe side you usually do something like this:

if (questionData.questionAudio != null && questionData.questionAudio.Length > 0)
    Audiosource.clip = questionData.questionAudio[0];

If you want to pick a random audio clip from the array you would do

Audiosource.clip = questionData.questionAudio[Random.Range(0, questionData.questionAudio.Length)];

I think this should cover most usecases.
[1]: Unity - Scripting API: AudioSource.clip