Collectible Objects Script Help Please

So, I want my character to be able to collect cheese cubes. I have the GUITexture positioned through the inspector, a GUIText (“Collected:”) that says that next to the texture, and then I have a blank GUIText (called “Counter”----creative, i know—) that is positioned next to it. I am getting no errors or compiler issues with this code, but it isn’t doing what I thought it would. I am a newbie, so please internets, tell me how to get an active counter of cheese cubes to show up on screen next to my GUITexture!

private var CollectedCheese : int= 0; //Set up a variable to store how many you've collected
public var collectedSound : AudioClip; 
var CheeseCube : GameObject;
var cheeseTexture : GUITexture;
var Counter : GUIText;

CheeseCube.SetActive(true); //Using True/False techno

function OnTriggerEnter (myTrigger : Collider) 
{
		if (myTrigger.gameObject.name == "Rat")
		{
			audio.PlayOneShot(collectedSound); //plays the sound assigned to collectedSound
            CollectedCheese++; //adds a count of +1 to the collected variable
            CheeseCube.SetActive (false); //turns the collectable off
        }
            
        if (CollectedCheese >= 1.0 + CollectedCheese)
        {
        	Counter.GUIText.text = ("CollectedCheese");
        	Counter.transform.localPosition.x=-390.2;
        	Counter.transform.localPosition.y=348.08;
        }
           
}

Please and thank you!

You can use a GUI.Label and just position it to show up beside your GUITexture. Another way is to use a TextMesh or a GUIText to display the amount you have collected.

Also, it seems you are storing the number of cheese collected on the cheese itself? You shouldn’t do that since you might have multiple instances of the number of cheese (and you’re counting how many times you collected the same cheese). What you should do is to store the variable on a single script that is only used once. Probably the player or your main GUI script.

You sir (or miss, haha), are wonderful. To my rescue again! Thank you!I The two script thing makes so much more sense! I’ll post how it goes