set a Transform variable through script

hi, i am trying to find a way to change a set a transform variable through script, like the title says

for example

public Transform target;

void Update()
{
     transform.LookAt(target);
}

If you happen to mean 'how can I set a new value for ‘target’ with a script? You just do it, examples:

public Transform target;

public Transform otherTarget;

void Update()
{
  if (Input.GetKeyDown("O"))
    target = otherTarget;
  if (Input.GetKeyDown("F"))
    target = GameObject.Find("SomethingElse").transform;

  transform.LookAt(target);
}