this is my script
using UnityEngine;
using System.Collections;
public class Collectables : MonoBehaviour {
public int scoreValue = 10; // The amount added to the player's score when the collectables destroy.
public AudioClip coinClip; // The sound to play when the collectables destroy.
AudioSource collectablesAudio; // Reference to the audio source.
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D (Collider2D other){
if (other.tag == "Player") {
Destroy(gameObject);
// Increase the score by the collectables score value.
ScoreManager.score += scoreValue;
collectablesAudio = GetComponent <AudioSource> ();
// Change the audio clip of the audio source to the Coin clip and play it
collectablesAudio.clip = coinClip;
collectablesAudio.Play ();
}
}
}