NullReferenceException object reference not set to an instance of an object.

public class RayCast : MonoBehaviour
{

public float distanceToSee;
RaycastHit whatIHit;
JournalText journaltext; 

// Use this for initialization
void Start () 
{
}

// Update is called once per frame
void Update () 
{
    Debug.DrawRay(this.transform.position, this.transform.forward * distanceToSee, Color.magenta);

    if (Physics.Raycast(this.transform.position, this.transform.forward, out whatIHit, distanceToSee))
    {
        if(Input.GetKeyDown(KeyCode.E))
        {
            //Debug.Log("I Touched " + whatIHit.collider.gameObject.name);
            if(whatIHit.collider.tag == "Journal")
            {
                //Debug.Log("tag: " + whatIHit.collider.tag);
                if(whatIHit.collider.gameObject.GetComponent<Interact>().whatBookAmI == Interact.Interacter.journal)
                {
                    //Debug.Log("I Touched " + whatIHit.collider.gameObject.name + "tag: " + whatIHit.collider.tag);
                    //Destroy(whatIHit.collider.gameObject);
                    JournalText journalText = GetComponent<JournalText>();
                    whatIHit.collider.gameObject.GetComponent<JournalText>().JournalPress();
                }
            }
        }   
    }
}

}

using UnityEngine;
using System.Collections;

[System.Serializable]
public class JournalPage
{
public Canvas journalPages;
}

public class JournalText : MonoBehaviour
{
public JournalPage journalPage;

void Start()
{
    journalPage.journalPages = journalPage.journalPages.GetComponent<Canvas>();
    journalPage.journalPages.enabled = false;
}

public void JournalPress()
{
    journalPage.journalPages.enabled = true;
}

}

I’m trying to get a image to appear when the person using the Oculus rift hits E on a book. Only problem i’m having is the image showing up.

First thing you should do is optimise that script a little. At the moment it looks like you are raycasting every single frame and then checking for an input if that raycast range is true. You’re better off raycasting on input and then checking that distance.

So I would switch it round like this for starters:

if(Input.GetKeyDown(KeyCode.E))
{
     if (Physics.Raycast(this.transform.position, this.transform.forward, out whatIHit, distanceToSee))
     {

The null reference is probably coming from if(whatIHit.collider.tag == "Journal") and could be resolved by appending an else to that condition or an if(example != null) elsewhere when trying to do something with the product of the raycast. First thing to do though is stop raycasting on every single frame.