Bullet follows new position

So I am making a game in unity2D js, and it is a top down space shooter, I have the character rotation down, and its movement, but I’m having trouble making it shoot. I want it so the player spawns a bullet, and the bullet goes to where the user clicked, and keeps going. However, what is happening is the player shoots somewhere, the bullet does excatly what its designed to, but then when you shoot another bullet, the first bullet goes where the second one is.

My Code:
#pragma strict

var mousePos : PlayerControls.mouse_pos;
var bulletSpeed = 15;

function Update(){

transform.position = Vector3(transform.position, mousePos.position, bulletSpeed * Time.detlaTime);

}

Please help, thanks!

Try this:

#pragma strict

var mousePos : PlayerControls.mouse_pos;
var bulletSpeed = 15;
 
private var thisBulletsTarget : float;
 
function Start () {
	thisBulletsTarget = mousePos.position;
}
 
function Update(){
	transform.position = Vector3(transform.position.x, thisBulletsTarget, bulletSpeed * Time.deltaTime);
}