Help with this script

Can someone please tell me what I’m doing wrong. I’m trying to have whenever the player looks at an item with the tag “pickup” be able to be recognized by the raycast and show a text saying “press e to pickup”.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Raycast : MonoBehaviour {

public GameObject pickUp;

private bool canHover = false;
                
void update ()
{
    var fwd = transform.TransformDirection(Vector3.forward);
    RaycastHit hit;

    if (Physics.Raycast(transform.position, fwd, hit))
    {
        if (hit.distance <= 5.0f && hit.collider.gameObject.tag == "pickup")
        {
            canHover = true;

            if(Input.GetKeyDown("e"))
            {
                Destroy(pickUp);
            }
        }

        else
        {
            canHover = false;
        }
    }
}
void OnGUI()
{
    if (canHover == true)
    {
        GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 150, 20), "Press E to Pick Up!");
    }
}

}

@Hellium that was a problem thank you but it didn’t fix it. The problem is at this line “if (Physics.Raycast(transform.position, fwd, hit))” it’s giving an error message for “hit” saying “Use of unassigned local variable ‘hit’”.

Are you sure the RayCast is hitting the object ? Try Debug.Log("Hit") or use Debug.DrawRay(Vector3 start, Vector3 dir, Color color = Color.white) to look where the RayCast is going.