audio playback problem not being triggered

var ButtonSpace: AudioClip;

var setTrigger : boolean = false;
function Update () {

  if (Input.GetKeydown (KeyCode.Space)&& !setTrigger) {

    if (!audio.isPlaying) {

      audio.loop = false;

      setTrigger = true;

      audio.clip = ButtonSpace; 





@script RequireComponent(AudioSource)

audio is not being played back when i press a key

It seems the problem is the Input.GetKeyDown - you’ve wrote Input.GetKeydown. You must be receiving runtime errors. Change the line to:

  if (Input.GetKeyDown (KeyCode.Space)&& !setTrigger) {

There’s something weird about this code: it will play only once, since setTrigger is set and nothing in the script reset its value. Is it an intended feature?