Function Update play sound once

public var acelerateSound: AudioSource; // its attached to refenrenced

function Update() 
	{
    if(Input.GetAxisRaw("Vertical") > 0 || Input.GetKey (KeyCode.Joystick1Button2))
      {
      accelerate = true;
      acelerateSound.Play();	
      }

    else
      accelerate = false;
    }

Problem is, if i keep the key down the sound overlaps itself and i want it ust to play when i press the key for the first time

When no buttons are held accelerate will be false, you can play the sound only if it’s false before setting it to true. As long as you hold the buttons down it will stay true, so it will not repeat.

if (Input.GetAxisRaw("Vertical") > 0 || Input.GetKey (KeyCode.Joystick1Button2)){
    if (accelerate == false){
        audio.Play();
    }
    accelerate = true;
}
else{
    accelerate = false;
}