destroy box collect points

i am trying to make a ball destroy different boxes and as these boxes are destroyed 100 points is collected. i just need the coding for when box is destroyed 100 points added but i cant seem to find where to start. please could someone help me?

For destroying after triggering:

function OnTriggerEnter(other : Collider) { // Kills the game object Destroy (gameObject); }

make sure is checked the Is Trigger on collider in object. As said before, if you have already players score variable, post the code, or let us know something more.

Alright Firstly Have a script which contains all of your gloabal variables (So they can be called from all scripts, I like this way it keeps it nice and tidy.

So you might have

VariableScript.cs

and this script contains

using UnityEngine;
using System.Collections;

public class VariableScript : MonoBehaviour {
    public static int score = 0;
        // All your other variables can be put in here.

}

And then in your collider script having something like this we will name it ColiderScoreAdder

using UnityEngine;
using System.Collections;

public class ColiderScoreAdder : MonoBehaviour
{

// ball hits box, adds score then box destroys self (You could also instantiate an //explosion effect or the box made into parts with some physics
public GameObject spawnedprefab;
public float      explodeSecs = -1;

void Awake()
{
        if(explodeSecs > -1) Invoke ("DestroyNow", explodeSecs);
}

void OnCollisionEnter( Collision collision )
{
    // Rotate the object so that the y-axis faces along the normal of the surface
    ContactPoint contact = collision.contacts[0];
    Quaternion   rot     = Quaternion.FromToRotation(Vector3.up, contact.normal);
    Vector3      pos     = contact.point;
    Instantiate(spawnedprefab, pos, rot);
    // Destroy the projectile
    Destroy (gameObject);
}

void DestroyNow()
{
    Instantiate(explosionprefab, transform.position, transform.rotation);
    AddScore();
    Destroy (gameObject);
}

void AddScore ()
{
   VariableScript.score +=1;
}
}

Then with some fancy Gui Text Updating you could display your score in game (For whom may wonder I did edit the Colider explosion script from unify wiki for this)

For the Gui Text add a GuiText displaying 0 as the score to your game then in an update in one of your scripts put this somewhere (I named the gui text g_Score in this)

    print("Score is Now: "+VariableScript.score);
    GameObject.Find("g_Score").guiText.text = ""+VariableScript.score;

All done in C# Sorry if it is the incorrect language, It will work 100% though (If I mispelt anything and you get errors ask what the error is in this thread as a comment to me)