Why is this not working? (527346)

Everything works fine, but the GUI label just shows 0 all the time ? i can see the “value” number counting up in my console but the GUI.label refuses to move from 0

using UnityEngine;
using System.Collections;

public class ResourceControl : MonoBehaviour
{
	public int[] AddResource;
	private int addResource = 0;
	public int OutResources;
	public int value;

	void Awake ()
	{
		PlaceableBuilding.collectOil += this.CollectOil; // when collectOil is called we call CollectOil below
		PlaceableBuilding.stopcollectOil += this.StopCollectOil;;  // when stopcollectOil is called we call StopCollectOil below
	}

	public void CollectOil()
	{
		AddResource = new int[2];
		addResource = addResource + 1; // This happens every 10seconds controll by another script
		AddResource[1] = addResource;
		int value = AddResource[1];
		Debug.Log(value);
	}

	public void StopCollectOil()
	{
		Debug.Log ("Need to code");
	}

	void OnGUI()
	{
		GUI.Label(new Rect(100, 200, 100, 100), value.ToString()); // THIS IS THE LINE THAT IS NOT WORKING JUST SHOWS O ALL THE TIME
	}
}

I don’t think that you have to use .ToString() so i would try it without that.

if i take .ToString() out i get these errors

The variable value that you are writing to the console in the CollectOil method is a local variable to that method (ie it is declared inside the method). This is not the same variable as the public int value that you declare at the top of the class, which is the one OnGUI is using.

ok im still new to coding :stuck_out_tongue: guess i need to decalare the AddResource[1] array publicly some how

YAY I FIXED IT thaanks for help, i simply changed

for

and

for