How do i access a variable from another script?

Hi. I want to check an int called buff, from another script (Player script). What i want is: when the buff=1, i want it to change my buffOn int to 1, which is placed in a different script than the player script. Right now i get this erroe “NullReferenceException: Object reference not set to an instance of an object
ToughBox.Update () (at Assets/ToughBox.cs:17)”

My script looks like this:

using UnityEngine;
using System.Collections;

public class ToughBox : MonoBehaviour {
public int buffOn;

// Use this for initialization
void Start () {


// Update is called once per frame
void Update () {	
    Player Pscript = GetComponent<Player>();
    if (Pscript.buff == 1)
        buffOn = 1;

The error is letting you know that Pscript is not correctly referenced to your instanced script. In other words, your GetComponent() method is not working.

For GetComponent to work both scripts must be attached to the same game object. Is this the case?

Also, there is rarely a need to call GetComponent from within Update (it slows things down). Assign your Pscript variable within Start or Awake instead.

public GameObject player; //attach the object with the script.
public NameofTheScript variable;

    	void Awake () {
    		variable = player.GetComponent<NameofTheScript> ();
    	// Update is called once per frame
    	void Update ()