Can not play a disabled audio source

Linus K 21 Reputation points
2022-08-21T12:06:15.703+00:00

pls help me
Erorr:Can not play a disabled audio source
UnityEngine.AudioSource:Play ()
CoinController:OnTriggerEnter2D (UnityEngine.Collider2D) (at Assets/Scripts/CoinController.cs:11)

Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoinController : MonoBehaviour
{
public AudioSource coinAudioSource;

private void OnTriggerEnter2D(Collider2D collider2D)  
{  
    coinAudioSource.Play();  
    Destroy(gameObject);  
}  

}

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,350 questions
{count} votes