Creating a teleportation gun

Hi, I’ve been trying to create a teleportation gun using raycasts and rigidbody’s.

I have made a basic raycast gun

    var bullet : Rigidbody;
    var bulletPoint : Transform;
    
    function Update () 
    {
    	var hit : RaycastHit;	
    	
    	if (Input.GetButtonDown("Fire1"))
    	{
    		var fwd = transform.TransformDirection (Vector3.forward);
    
    		if (Physics.Raycast (transform.position, fwd))
    			print ("Raycast Hit!");
    		else
    			print ("Raycast Didn't Hit!");
    
    		var bulletInstance : Rigidbody;
    
    		bulletInstance = Instantiate(bullet, bulletPoint.position, bulletPoint.rotation); //Object to clone, origin of bullet, rotation
    		bulletInstance.AddForce(fwd * 500); //Moving projectile
    		
            Quaternion.LookRotation(hit.normal));
    	}
    }

I also have a basic teleport script:

var target : Transform;

function Update () {
 
}
 
function OnTriggerEnter (col : Collider) {
 
        if(col.gameObject.tag == "teleport") {
                this.transform.position = target.position;
        }
}

I’m trying to combine these two, so when the projectile hits a wall, it teleports the player to where it hit.

Any help is greatly appreciated.

I got it working!

Gun Script:

#pragma strict

var bullet : Rigidbody;
var bulletPoint : Transform;
var teleport;

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

        if (Physics.Raycast (transform.position, fwd))//Check if raycast hit
            print ("Raycast Hit!");
        else
            print ("Raycast Didn't Hit!");

        var bulletInstance : Rigidbody;

        bulletInstance = Instantiate(bullet, bulletPoint.position, bulletPoint.rotation); //Object to clone, origin of bullet, rotation
        bulletInstance.AddForce(fwd * 500); //Moving projectile
        //Destroy (bulletInstance.gameObject, 1);
        
        //Quaternion.LookRotation(hit.normal);
    }
}

Teleport Script:

var target : Transform;
var player : GameObject;

function OnTriggerEnter( col : Collider )
{
	player = GameObject.Find("Player");
	
	if(col.gameObject.tag == "teleport")
		player.transform.position = target.position;
}