Audio not playing

Hi all,
I am a newbie in Unity
What I am trying to do is play an audio when player collects a coin.
Can anyone help me out with that?
I tried many tutorials but it just doesn’t want to work.

It is actually kinda complicated to answer in text, but i hope you understand. I would need more info to make something more solid (Is the game 3D or 2D, are you using C# or Javascript,etc…)

First, you will need to make some variables, that will hold both your audio and your coin:

public GameObject yourcoin;
public AudioSource youraudio;

Then you will need to make a function so when you collect your coin, the sound will be displayed. For this, we are going to use OnTrigger to detect when the Player has hit the coin. If your coin already has a collider, just check the “Is Trigger” checkbox. If it isn’t, then make one.

  void OnTriggerEnter(Collider other)
{

}

Then you just need to make a code to play your Audio when the Player hit the coin. For this, you can use AudioSource.Play(). As we already made a variable, we can just use:

youraudio.Play();

So, our script would be like:

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour
{
        public GameObject yourcoin;
        public AudioSource youraudio;

        void OnTriggerEnter(Collider other)
        {
            youraudio.Play();
        }
}

Then you just need to attach the script to your coin. I hope you get it. Comment if you still need assistance. As i said, there isn’t much info so this is just an example.