Add a OnTriggerExit function (and make sure the object.name that is exiting the trigger is the same object.name that had entered the trigger). if the object.name’s match, you can increment your counter then. does this make sense?
var attemptsCounter : GuiText; // Add a guiText here
var destination : Transform; // Where you want the player to spawn when it collides with the object.
var attempts = 0;
function OnTriggerEnter (hit : Collider)
{
if(hit.gameObject.tag == "Give the object you are colliding with a tag and write it here")
{
transform.position = destination.position;
attempts += 1;
}
}
function Update ()
{
attemptsCounter.text = ""+ attempts;
}
Attach this to your player.
Very easy just adding a variable called attempts that gets added to when the player collides with the object and printing it out on a GUIText.