Engine noises creation

Okay so I want to create a racing game. I know its a bit of a stupid question, and i might be asking too much. but could somebody tell me a script that would be a bit like this

If car.speed = 10 then
play sound1
if car.speed = 20 then
play sound2 

abit like that, any ideas?

I think you're pretty much there with your pseudocode. Maybe something like this (untested):

// define variables for the car, speed and sounds
// you will need to assign these in the editor
var car : GameObject;
var speed : int;
var idleSound : AudioClip;
var firstGearSound : AudioClip;
var secondGearSound : AudioClip;

// initially set speed to zero
function Start(){
  speed = 0;
}

function Update(){

  if(speed==10){
    // set the default audio clip to value stored in this variable
    audio.clip = firstGearSound;

  } else if(speed == 20){
    audio.clip = secondGearSound;

  } else {
    audio.clip = idleSound;
  }

    // play the default audio clip
    audio.Play();
}

// make sure this gameobject has an audiosource attached for it to play sounds
@script RequireComponent(AudioSource)

I don't drive so the first/second gear names are purely arbitrary! You'd probably want different sounds for gear changes and engine revs and it might be better to use speed ranges rather than fixed amounts. There's a detailed car tutorial here which you might find useful. I haven't actually tried switching sounds immediately like i'm suggesting above so you may find it isn't as smooth as you'd like. You might then have to look into crossfading between sounds for a smooth transition.

Good luck.