gunshot distance

I got my gun to shoot but when I want to shoot an object that is close the player it doesn’t work.

I have no idea what is causing this so your help would be most appreciated.

here is my shooting JS

var range= 100.0;
var force=10.0;
private var hitParticles : ParticleEmitter;


function Start ()
{
	hitParticles = GetComponentInChildren(ParticleEmitter);

	if (hitParticles)
	{
		hitParticles.emit = false;
	}
}


function Update ()
{
	if( Input.GetButtonDown( "Fire1" ) )
	{
		var direction = transform.TransformDirection(Vector3.forward);
		var hit : RaycastHit;

		if (Physics.Raycast (transform.position, direction, hit, range))
		{
			
			if (hit.rigidbody)
			{
				hit.rigidbody.AddForceAtPosition(force * direction, hit.point);
			}
			
			if (hitParticles)
			{
				hitParticles.transform.position = hit.point;
				hitParticles.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
				hitParticles.Emit();
			}
			
		}
	}
}

The Raycast starts in “transform.position” parameter of the function so it depends which object has the Shooting.js script attached and his exact position.

Ok thank you.
What I did was put the script in an empty object and made my gun and sparks a child of that but I forgot to move the object into place first.
thanks