Unity Raycast Script, Help!

Hi. My problem is that: I create this script:

var blue : GameObject;
static var mozna : boolean = false;
static var moznaa : boolean = false;

function Update () {
var hit : RaycastHit;
if(Physics.Raycast (transform.position, transform.forward, hit, 1000)){
mozna=true;
if(moznaa==true){
var Newblue : GameObject;
Newblue = Instantiate(blue, hit.collider.gameObject.transform.position, hit.collider.gameObject.transform.rotation);


}
}
}

And when I shoot in a wall, blue create at the central point this wall. I want to create at any point no on a central point. Please Help!

To get the position correct use hit.point. You may want to bring the object out just a bit to avoid ‘z’ fighting. I’ll have to guess on the rotation since I don’t know the natural orientation of blue. Typically this kind of code would use a horizontal plane:

Newblue = Instantiate(blue);
blue.transform.position = hit.point + hit.normal * 0.01;
blue.transform.rotation = Quaternion.FromToRotation(transform.up, hit.normal) * blue.transform.rotation;