how to use raycasthit.point?

i have this script that is supposed to teleport the player to where the mouse is looking by instantiate and destroying itself. it is attached to the player and i know im close but i cant figure out what im doing wrong with raycasthit.point and why im causing so many compiler errors

public bool tpcooldown;
private Transform tpos;
public GameObject playerprefab;
// Use this for initialization
void Start()
{
    
}

// Update is called once per frame
private void Update()
{
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;
    Physics.Raycast(ray, out hit);
}
void teleport()
{
    tpcooldown = false;
    Instantiate(playerprefab, hit.point, Quaternion.identity );
    Destroy(gameObject);
}

Because the variable hit is local to the Update method. Make it a field variable (put it all the way up where the others are declared) so teleport can access it.