Lock a target with mouseclick

Hi, I’d like to create a target system like in classic mmorpg.

When I Left click on an enemy, it save it as a Target. (with an arrow on his head)
When I click on a spell, the spell go to my current target.

Actually I try to do the target script.

I have this script for create the arrow on my enemy’s head
But I have the problem "Cannot convert ‘UnityEngine.GameObject’ to ‘UnityEngine.Transform’.
"

And how this arrow can follow my enemy ?

var hit: RaycastHit;
var ray;
private var target : Transform;
var targetScript : Target;

function Update()
{
    CheckClick();
}
     
function CheckClick()
{
    if (Input.GetButtonDown("Jump") ||Input.GetButtonDown("Fire1"))
    {
    Debug.Log("space");
    if (Physics.Raycast(ray, hit, 100))
       {
    if (hit.collider.tag == "Enemy")
          {
    target = hit.collider.gameObject;
    var posetarget = Instantiate(target, transform.position, Quaternion.identity);
    targetScript = posetarget.GetComponent(Target);
    Counter=0;
    
          }
       }
    }
}

Try:

var posetarget = (Transform)Instantiate(target, transform.position, Quaternion.identity);

You can make the arrow Find the enemy object with a tag, then apply a speed to the arrow.
Getting the distance from the arrow to the enemy making the arrow reach the enemy position, i have the code but im not in my computer right now.