MachineGun script applied damage to the object that is not hit.

Here is my script that I have modified from the FPS Tutorial. I have made it so that it has a random spread rather than dead on accurate fire.

function FireOneShot (shotOwner : boolean, hitPoint : Vector3, hitNormal : Vector3) {
    var direction = SprayDirection();
    var hit : RaycastHit;
    print("shot");
    // Did we hit anything?
    //Invoke("muzzleClimb", 0.3);
if(shotSpread <= spreadMax)
        shotSpread += spreadClimbAmount;
    if (Physics.Raycast (transform.position, direction, hit, range)) {
    var settingsArray = new String[2];
            settingsArray[0]=damage+"";
            settingsArray[1]=localPlayerName;

            hit.collider.SendMessage("ApplyDamage", settingsArray, SendMessageOptions.DontRequireReceiver); 
        // Apply a force to the rigidbody we hit
        if (hit.rigidbody)
            hit.rigidbody.AddForceAtPosition(force * direction, hit.point);

        var go : GameObject;

        var delta : float = -0.02;
        var hitUpDir : Vector3 = hit.normal;
        hitPoint = hit.point + hit.normal * delta;

        //what type of object did we hit?
        switch(hit.collider.gameObject.tag)
        {
            case "wood":
                go = Network.Instantiate(woodParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "metal":
                go = Network.Instantiate(metalParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "concrete":
                go = Network.Instantiate(concreteParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "dirt":
                go = Network.Instantiate(sandParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "explosive":
                var expObject : explosiveObject = hit.collider.gameObject.GetComponent(explosiveObject);
                expObject.hitTimeCount +=1;
                go = Network.Instantiate(metalParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "sand":
                go = Network.Instantiate(sandParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "water":
                go = Network.Instantiate(waterParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            case "acid":
                go = Network.Instantiate(acidParticle, hit.point, Quaternion.FromToRotation(Vector3.up, hitUpDir), 0);
                break;
            default:
                return;
        }
        // Send a damage message to the hit object          
        hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
    }
    bulletsLeft--;

    // Register that we shot this frame,
    // so that the LateUpdate function enabled the muzzleflash renderer for one frame
    m_LastFrameShot = Time.frameCount;
    enabled = true;

    // Reload gun in reload Time        
    if (bulletsLeft == 0)
        Reload();           
}

and here is the function for making the direction random. l

function SprayDirection() {
var vx = (1 - 2 * Random.value) * shotSpread;
var vy = (1 - 2 * Random.value) * shotSpread;
var vz = 1.0;
return transform.TransformDirection(Vector3(vx,vy,vz));
}

The problem I am having is that on this line

 hit.collider.SendMessage("ApplyDamage", settingsArray, SendMessageOptions.DontRequireReceiver); 

It still applies the damage to the item in the immediate forward direction rather than the random area. help is appreciated :)

What is not working about this script is lets say I looked straight on to another player and I shot. You could see sparks instantiated in the correct random area, but instead of damage being applied to that object, it was applied to the player because he was in the immediate forward direction of me.

Solved. I dont know how I fixed it lol.