Trying to assign GUIText from heirarchy into instantiated prefab

Sorry if this question is silly, I’m still a real novice at Unity (and programming). So, I have a player with the following script written:

	public GUIText countText;
	public GUIText winText;
	private int count;

	void OnTriggerEnter(Collider other) {
	    if(other.gameObject.tag == "PickUp"){
		other.gameObject.SetActive(false);
		count = count - 1;
		SetCountText ();
	    }
	}
		
	void SetCountText() {
	        countText.text = "Count: " + count.ToString ();
		if(count == 0){
		       winText.text = "YOU WIN!";
		}
	}

The problem is that the player is instantiated, so I can’t assign the GUIText “countText” or “winText” onto the prefab (I think). Could someone please lecture me on some snippet that might point me in the right direction? Many thanks!

Since a prefab can be Instantiated into multiple scenes, you cannot link a variable by dragging and dropping a scene item. The typical solution is to use GameObject.Find() or GameObject.FindWithTage() in Start() to create the linkage.

void Start() {
    countText = GameObject.Find("CountText").guiText;
    winText = GameObject.Find("WinText").guiText;
}

Note that 'CountText and ‘WinText’ are just examples. You need to set them to whatever you’ve named your two GUIText objects. Also the ‘countText’ and ‘winText’ variables are better off as ‘private’ when initialized in Start().