Activating Audio When Hitting a collider

Okay HEYYYY i was just wondering how i would activate an audio source when hitting a collider i thought it would be like the code below but it does not seem to work :confused:

function OnTriggerEnter (Hit : Collider)

{
AudioSource.Play(“Name Of the Audio”);
{

This Method doesn’t Work And i was wondering if somebody could help, or point me in the right direction :smiley: thanks for reading :smiley:

Im reasonably new to coding, but maybe try changing

AudioSource.Play(“Name Of the Audio”);

to

audio.Play();

and add an audio source to the object and uncheck ‘loop’ and ‘play on awake’

not too sure, hope this helps.

First, make sure you close the function with a closing bracket }, not another open bracket. Next, as GoThXoRd mentioned, you should use

audio.Play();

with the audio on the game object (you can just drag it on in the inspector, even).

If you are still having troubles, the following must be true for that function to work:

If you don't want the collider to be a trigger, use OnCollisionEnter()