Randomly mp3 sript, playing just first song

Hi, please help me with this i don’t know what i’m doing bad. I’m trying to make music, that play randomly, but i don’t know how to do that. Thanks.

using UnityEngine;
using System.Collections;

public class Music : MonoBehaviour {

	public Object[] myMusic; // declare this as Object array
	void Awake () {
		myMusic = Resources.LoadAll("Music",typeof(AudioClip));
		GetComponent<AudioSource>().clip = myMusic[0] as AudioClip;
	void Start (){
		GetComponent<AudioSource>().Play ();
	// Update is called once per frame
	void Update () {
	void playRandomMusic() {
		GetComponent<AudioSource>().clip = myMusic[Random.Range(0,myMusic.Length)] as AudioClip;

Hmmm Try using an audioclip insted of an object. Try this. Never tried this but should work.

public AudioClip[] Sounds;
	void Update(){
		if(!GetComponent<AudioSource>().isPlaying){ PlayRandomMusic(); }
	void PlayRandomMusic(){
		int i = (int)Random.Range (0, Sounds.Length);
		GetComponent<AudioSource>().PlayOneShot(Sounds*, 1F);*
  • }*