It starts, then you destroy the speaker.

The problem
The speaker goes with the coin.
void OnTriggerEnter( Collider other ){ if ( !other.CompareTag( "Player" ) ) return; GetComponent<AudioSource>().Play(); Destroy( gameObject );}
The AudioSource is on the coin. Destroy the coin and the sound is cut off before you hear it.
The fix
Play it somewhere that stays.
PlayClipAtPoint makes a temporary speaker at a position, plays the clip, and cleans itself up.
clip+position→PlayClipAtPoint
The fix in code
One static call.
[SerializeField] AudioClip clip; void OnTriggerEnter( Collider other ){ if ( !other.CompareTag( "Player" ) ) return; AudioSource.PlayClipAtPoint( clip, transform.position ); Destroy( gameObject );}
The coin can go right away. The sound has its own object now.
Watch out
It's a 3D sound.
PlayClipAtPoint plays at that spot in the world, so it's quieter the farther it is from the listener.
- Next to the camera
- full volume
- Across the map
- quiet
- Menu clicks
- a 2D AudioSource
The rule
About to destroy it? Don't let it carry the sound.
- Pickup sounds
- PlayClipAtPoint
- Then
- Destroy( gameObject )
- Menu sounds
- a 2D AudioSource