Replace "Transform" by my Mouse Target

Hi actually I have this shot script

var bullet : Transform;
    var speed = 16000;
    var Speed = 300;
    var spawnPoint : Transform;
    var rapidFire = false;
    var counter = 0.0;
    var rateOfFire = 0.25;
    var ennemydeux : Transform;
    
    
    
     
    function Update ()
    
    
    {
    CheckClick();
    }
     
    function CheckClick()
    {
    if(Input.GetButtonDown("Fire1") || (rapidFire && Input.GetButton("Fire1")))
    {
    var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hit : RaycastHit;
    // you can set the 100 to whatever distance you want :P
    if (Physics.Raycast(ray,hit,100))
    {
    var enemy = hit.transform.GetComponent(ennemy);
    if(hit.transform.GetComponent(ennemy))
    {
    transform.LookAt(ennemydeux);
    HandleFiring();
    }
    }
    }
    }
     
    function HandleFiring()
    {
    if(rapidFire)
    {
    counter += Time.deltaTime;
    // I'm going to assume RateOfFireCounter is a variable that you've not shown here? Otherwise this won't do anything for you...
    if(rateOfFire)
    {
    var shotRapid =Instantiate(bullet, spawnPoint.transform.position, Quaternion.identity);
    shotRapid.rigidbody.AddForce(transform.forward * speed);
    shotRapid.transform.LookAt(ennemydeux);
    shotRapid.transform.Translate(Vector3.forward*Speed*Time.deltaTime);
    Destroy((shotRapid.gameObject), 2);
    
    Counter=0;
    }
    }
    else
    {
    var shot = Instantiate(bullet, spawnPoint.transform.position, Quaternion.identity);
    shot.rigidbody.AddForce(transform.forward * speed);
    shot.transform.LookAt(ennemydeux);
    shot.transform.Translate(Vector3.forward*Speed*Time.deltaTime);
    Destroy((shot.gameObject), 2);
    }
    
    
    }

I’d like to replace “enemy” and “ennemydeux” by my MouseTarget but I dont know how to do it.

I tried to replace var ennemydeux : Transform; by var ennemydeux : RaycastHit; but I dont work. (error with th lookat)

ty for any help !

Yo!

var bullet : Transform;
var speed = 16000;
var Speed = 300;
var spawnPoint : Transform;
var rapidFire = false;
var counter = 0.0;
var rateOfFire = 0.25;
var ennemydeux : Transform;

function Update()
{
	CheckClick();
}

function CheckClick()
{
	if (Input.GetButtonDown("Fire1") || (rapidFire && Input.GetButton("Fire1")))
	{
		var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		var hit : RaycastHit;
		// you can set the 100 to whatever distance you want :P
		if (Physics.Raycast(ray, hit, 100))
		{
			ennemydeux = hit.collider.transform;
			transform.LookAt(ennemydeux);
			HandleFiring();
		}
	}
}

function HandleFiring()
{
	if (rapidFire)
	{
		counter += Time.deltaTime;
		// I'm going to assume RateOfFireCounter is a variable that you've not shown here? Otherwise this won't do anything for you...
		if (rateOfFire)
		{
			var bulletScript : Bullet;
			var shotRapid = Instantiate(bullet, spawnPoint.transform.position, Quaternion.identity);
			bulletScript = shotRapid.GetComponent(Bullet);
			bulletScript.cible = ennemydeux.gameObject;
			shotRapid.transform.LookAt(ennemydeux);
			Destroy((shotRapid.gameObject), 2);
			Counter=0;
		}
	}
	else
	{
		var shot = Instantiate(bullet, spawnPoint.transform.position, Quaternion.identity);
		
		bulletScript = shot.GetComponent(Bullet);
		bulletScript.cible = ennemydeux.gameObject;
		shot.transform.LookAt(ennemydeux);
		Destroy((shot.gameObject), 2);
	}
}

Bullet.js: [Avec un B majuscule!]

#pragma strict

var speed = 300;
var cible : GameObject;

function Update (){
    if (cible != null)
        this.transform.position += (this.cible.transform.position - this.transform.position).normalized * this.speed * Time.deltaTime; 
}

J’ai testé, et c’est approuvé. =D