Raycasting gives NullReferenceException?

Full error: NullReferenceException: Object reference not set to an instance of an object
Inventory_Manager.Update () (at Assets/My Scripts/MainScene/Inventory System/Inventory_Manager.cs:105)

    RaycastHit hit; //has all the info about the object (name, tag, component etc....)

        Physics.Raycast(mainCamera.transform.position/*Origin*/, mainCamera.transform.forward/*Direction*/, out hit/*referenced hit*/, 3);

        if (hit.collider.gameObject.tag == "Item") // <<----- LINE 105
        {
            lookingAtContainer = false;
            showGUI = true; //show pickup prompt
            pickupPrompt.text = "Hit E to pick up: " + hit.collider.gameObject.GetComponent<Item_Info>().itemName; //show pick up prompt "Hit E to pick up: " plus what ever item you're mlooking at. The raycast looks at the script and check the name given to the item
        }
        else if (hit.collider.gameObject.tag == "Container")
        {
            lookingAtContainer = true;
            showGUI = true; //show pickup prompt
            pickupPrompt.text = "Hit E to open the: " + hit.collider.gameObject.GetComponent<Object_Info>().objectName; //show pick up prompt "Hit E to pick up: " plus what ever item you're mlooking at. The raycast looks at the script and check the name given to the item
        }
        else
        {
            lookingAtContainer = false;
            showGUI = false;
            pickupPrompt.text = "";
        }

You simply forgot to check the return value of your Raycast. If the Raycast function returns false, nothing was hit and the hit structure won’t contain any information.

RaycastHit hit; 
if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.forward, out hit, 3))
{
    if (hit.collider.gameObject.tag == "Item")
    {
        lookingAtContainer = false;
        showGUI = true; //show pickup prompt
        pickupPrompt.text = "Hit E to pick up: " + hit.collider.gameObject.GetComponent<Item_Info>().itemName;
    }
    else if (hit.collider.gameObject.tag == "Container")
    {
        lookingAtContainer = true;
        showGUI = true; //show pickup prompt
        pickupPrompt.text = "Hit E to open the: " + hit.collider.gameObject.GetComponent<Object_Info>().objectName; 
    }
    else
    {
        lookingAtContainer = false;
        showGUI = false;
        pickupPrompt.text = "";
    }
}

You might want to read the documentation more carefully :wink:

you need to add a redundancy into that script

after

Physics.Raycast(mainCamera.transform.position/*Origin*/, mainCamera.transform.forward/*Direction*/, out hit/*referenced hit*/, 3);

add

if(hit.collider != null){

and close that off at the end of the function.