Hello Unity Answers,
I have collected some script from the internet and have tried to put it together. Unfortunately, I am new to coding and I don’t even know how to lay it out properly. Would anybody care to fix it for me? It plays a sound when I enter an area, but I have broken it trying to make play once (so if you go back in said area it doesn’t play again). Thanks!
#pragma strict
var scareSound:AudioClip;
var hasPlayed = false;
function OnTriggerEnter(o:Collider){
audio.PlayOneShot(scareSound);
if(!hasPlayed){hasPlayed = true;
}