GUI text Messages does not show and points counter do not stop at its prefixed limit

In my game the Player has to collect apples (like Penelope collects Orbs). Everything is working OK except that the the counter of apples (should stop in 5) that continues adding apples and the warning GUI message inside the function Pickup (else statement), which does not show the message "You can't carry any more apples". Thanks in advance for any help.

var carrying : int; var carryLimit : int; var deposited : int; var winScore : int; var appleCollect : AudioClip;

var carriedGui : GUIText;

var depositedGui : GUIText;

var guiMessage : GameObject;

private var timeSinceLastPlay : float;

public function Start() {

timeSinceLastPlay = Time.time;
UpdateCarryingGui();
UpdateDepositedGui();

}

function UpdateCarryingGui() { carriedGui.text = "Carrying: " + carrying + " of " + carryLimit; }

function UpdateDepositedGui() { depositedGui.text = "Deposited: " + deposited + " of " + winScore;

}

function Pickup()

{ if ( carrying < carryLimit ) { carrying++; UpdateCarryingGui();

}</p>
else
{
    var warning : GameObject = Instantiate( guiMessage );
    warning.guiText.text = "You can't carry any more apples";
    Destroy(warning, 2);
}

} function OnTriggerEnter(collisionInfo : Collider) { if(collisionInfo.gameObject.tag == "apple") { carrying++; UpdateCarryingGui(); audio.PlayOneShot(appleCollect); Destroy(collisionInfo.gameObject); } }

you should be calling Pickup() in OnTriggerEnter() instead of just incrementing. As for your GUIText I would guess that either your camera doesn't have a GUILayer component or the position of your text is off the screen. GUIText transforms are in screen space so if you want it in the middle of the screen you put it at 0.5, 0.5.

The problem seems to be that there is no update to update the variables as you play through. You just set them and that's where they stay.

Put the following inside a function Update call:

function Update()
{
    var carrying : int;
    var deposited : int;
}

Since the limit of how many can be carried probably won't change, that can stay out. Same with win amount.