GuiText Problem

Sup, guys. I’ve written the next script:

using UnityEngine;
    using System.Collections;
    
    public class Gold : MonoBehaviour {
    	private KingController KingController;
    	
    	void Awake() {
    	KingController = GetComponent<KingController>();	
    	}
//comment
    	void Update () {
    	string format = System.String.Format("Gold:", KingController.Gold);	
    	guiText.text = format;
    	
    	}
    }

But Unity says that 12 lane cause this error:
16466-screenshot.jpg
I wanted to display int “Gold”, taken from other script, but something goes wrong.
Don’t get it, what’s wrong =( Help pls

I would say instead of using getComponent trash that row and in the KingController script add this line instead of your declaration:

public int Gold { get{ return gold; } set{ gold=value; } }

Now you only need to type KingController.gold in your Gold class and it’s better because you can both get and change (set) the variable in your Gold class.

And are you sure that you have spelled KingController right, in all ways (capital letters) and such? That was a problem I had.