audio for moving platforms

hi all i am wanting to add a sound to a moving platform, so that it doesn't become out of sync i am wanting the audio to play when the platform starts moving and not a audio loop, this is the way point script

function OnDrawGizmos() {
    Gizmos.DrawIcon(transform.position, "platformIcon.tif");

} 

i have tried this script but alas it doesn't work im a complete novice at scripting

public AudioClip ActivateSound;
function OnDrawGizmos() {
    Gizmos.DrawIcon(transform.position, "platformIcon.tif");

    AudioSource.PlayClipAtPoint(ActivateSound, transform.position);
}

would anyone be able to tell me whats wrong with it?

cheers Matt

OnDrawGizmos() is used for drawing editor and debug graphics in the scene window (and the game window, if gizmos are enabled for that view). In the code you posted, it's used to draw an icon to make it easier to identify and select waypoint objects (which presumably don't have any other visual aspect associated with them).

That's really all OnDrawGizmos() is for, so you probably don't want to put any game logic in that function. If you want the sound to play when the platform starts moving, you'll need to put that statement with the rest of the corresponding code. I don't know where that is in your code (it could be in Update(), OnTriggerEnter(), etc.), so I can't really be more specific than that. I can tell you with a fair amount of certainty though that OnDrawGizmos() isn't the right place for it :)