Syntax error: object reference is required

i’m making a sort of flappy bird game but i dont know the solution for this:
here’s the PlayerController script

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

public TextMesh highscoreText;
public int score = 0;
// Use this for initialization
void Start () {
isStartButtonPressed = false;
Time.timeScale = 0.0f;
}

// Update is called once per frame
void Update () {
updateScore();
if(!isInView())
{
restartGame();
}
if(Input.anyKeyDown)
{
move();
}
}

private bool isInView()
{
Vector3 port = Camera.main.WorldToViewportPoint(transform.position);
if((port.x < 1) && (port.x > 0) && (port.y < 1) && (port.y > 0) && port.z > 0)
{
return true;
}
else
{
return false;
}

}

private bool isStartButtonPressed;
public GUIText scoreLabel;
void OnGUI()
{
if (!isStartButtonPressed)
{
GUI.TextField(new Rect(Screen.width/2-65, Screen.height/2-11 ,130,22), "Tap to start");
if(Input.anyKeyDown)
{
Time.timeScale = 1.5f;
isStartButtonPressed = true;
}
}
}

private void move()
{
rigidbody.velocity = new Vector3(0,0,0);
rigidbody.AddForce (new Vector3(170,340,0), ForceMode.Force);
}

void OnTriggerEnter(Collider other)
{
	restartGame();
}

private void restartGame()
{
Application.LoadLevel ("mainmenu");
Time.timeScale = 0.0f;
isStartButtonPressed = false;
}

private void updateScore()

{
int score = (int) (transform.position.x / GenerateWorld.distanceBetweenObjects);
if(score != (int.Parse(scoreLabel.text)) && score > 0)
{
scoreLabel.text = score.ToString();
}

}

	
}

and here is the HighScore script

    using UnityEngine;
    using System.Collections;
     
    public class Score : MonoBehaviour {
    
    public int highScore = 0;
    string highScoreKey = "HighScore";
     
    void Start(){
    //Get the highScore from player prefs if it is there, 0 otherwise.
    highScore = PlayerPrefs.GetInt(highScoreKey,0);
    }
     
    void Update(){
    guiText.text = "HighScore:" + highScore.ToString();
    }
     
    void OnDisable(){
     
    //If our scoree is greter than highscore, set new higscore and save.
    if(PlayerController.score>highScore){
    PlayerPrefs.SetInt(highScoreKey, score);
    PlayerPrefs.Save();
    }
    }
     
    }

and I get this

24261-sadfsfasdf.jpg

pls help guyz. I have faith in you :slight_smile:

Your are trying to access the score variable from PlayerController, but it is not a static variable… only the PlayerController can see it the way it is. You either need to use GetComponent:

or make score a public static int;