Error: Ambiguous reference 'audio': Music.audio, UnityEngine.Component.audio.

Hi,

I am trying to play the sound Xylo_13 at the beginning of the game but it always returns with:
Assets/Music.js(9,1): BCE0004: Ambiguous reference ‘audio’: Music.audio, UnityEngine.Component.audio.
My code is here:

#pragma strict

@RequireComponent(AudioSource)
public var Xylo_13: AudioClip;
var audio: AudioSource;

function Start() {
audio = GetComponent.<AudioSource>();
audio.PlayOneShot(Xylo_13, 0.7F);
}

function Update () {

}

I don’t quite know what’s wrong. I’m following the template Here:

Please help as I can’t progress my game any further until I figure this out. Thanks.

Sorry guys, looks like I solved this by myself. For anyone having this issue: I changed audio to audi and it works… (I still feel kinda like I’m cheating it was so easy)

1 Like

I had exactly the same problem. I changed my var audio to var audi and my script suddenly worked. I suppose audio must be a keyword from the previous versions and should be avoided in 5.6.0p3 as a variable. Audio as a variable worked too. My script was in javascript.