An object reference is required to access non-static member

Hi i’m quite new to unity c# scripting and I am stuck with this error. I keep trying to access the coinController.points variable from another script but it just shows me the “An object reference is required to access non-static member” error.

using UnityEngine;
using System.Collections;

public class PlanningStage : MonoBehaviour {

    public string startgame;
    public bool hasProtein;
    public int totalCoin = 0;

    public void newLevel(){
        Application.LoadLevel (startgame);

    }


    void start () {
        coinController points = GetComponent<coinController>();
        totalCoin += coinController.points;
        hasProtein = false;

   
   
   
    }
    // Update is called once per frame
    void Update () {
       




    }
}

First of all, a class namr should be something starting with an uppercase letter
Your problem:
You just got an instance of the coinContoller class tgere, so instead of coinController.points,do points.points. If you have a variable inside a class, and its not static, you can only grt it, if you have an instance of that class

omg thankyou so much :smile: