how to add an audio source to a variable

I am trying to add a song so that when an enemy gets hit it makes a sound.

I can’t get the sound into the script. please help

Use this:

public AudioSource audio;

Assign the AudioSource of the object to this variable via Inspector. Alternatively, you can get the AudioSource in Awake:

audio = GetComponent<AudioSource> ();

Then in the code where you check if the enemy is hit, you play the sound:

audio.Play ();