play sound when collide?

hi does anyone know a script or can anyone make a script that plays a sound (1) time when the player collides

try this

var crashSound : AudioClip; // set this to your sound in the inspector

function OnCollisionEnter (collision : Collision) {
    // next line requires an AudioSource component on this gameobject
    audio.PlayOneShot(crashSound);
}

http://unity3d.com/support/documentation/ScriptReference/AudioSource.PlayOneShot.html

Here's my approach, for if you want to play more than one collision sound:

var thud:AudioClip;
var ping:AudioClip;

function OnCollisionEnter(collision:Collision)
{
    if (collision.collider.material.staticFriction == 0.25f)    // This is how I decided to determine if a PhysicMaterial was metal
        audio.PlayOneShot(ping);
    else
        audio.PlayOneShot(thud);
}

I haven't tested it out honestly, but I know that this should work. If you don't like what I used to determine if a collider's material was metal or not, then you could pick some other attribute of the metal PhysicMaterial that you think is unique.

Something like this:

function OnCollisionEnter(collision : Collision) {
   if (collision)
   audio.Play();
}

Not tested

I got most of this from the reference: http://unity3d.com/support/documentation/ScriptReference/Collider.OnCollisionEnter.html