How can I turn this Mouse Click Based Terrian Destruction Code into Code that I can use on a BulletScript(Terrain Destruction via Weapon Damage)?

private var tData : TerrainData;
private var saved : float[,];
var cratertex : Texture2D;
var xRes;
var yRes;
var craterData;

function Start () {
tData = Terrain.activeTerrain.terrainData;
xRes = tData.heightmapWidth;
yRes = tData.heightmapHeight;
saved = tData.GetHeights(0,0,xRes,yRes);
craterData = cratertex.GetPixels();
}
function OnApplicationQuit () {
tData.SetHeights(0,0,saved);
}
function Update () 
{
if (Input.GetMouseButtonDown(0))
	{
	var x : int = Mathf.Lerp(0, xRes, Mathf.InverseLerp(0, tData.size.x, mouse.mousepos.x));
	var z : int = Mathf.Lerp(0, yRes, Mathf.InverseLerp(0, tData.size.z, mouse.mousepos.z));
	x = Mathf.Clamp(x, cratertex.width/2, xRes-cratertex.width/2);
	z = Mathf.Clamp(z, cratertex.height/2, yRes-cratertex.height/2);
	var areaT = tData.GetHeights(x-cratertex.width/2, z-cratertex.height/2, cratertex.width, cratertex.height);
		for (i = 0; i < cratertex.height; i++) {
		for (j = 0; j < cratertex.width; j++) {
			areaT [i,j] = areaT [i,j] - craterData[i*cratertex.width+j].a*0.01;
		}
		}		
	tData.SetHeights(x-cratertex.width/2, z-cratertex.height/2, areaT);	
	}
}

You could tag your bullet with a name. Then in OnCollisionEnter function, add an if statement to find your game’s tag.
For example:

function OnCollisionEnter (collision: Collision){
        if (collision.gameObject.tag = "nametag"{
                ...the rest of your code...}

attach it the bullet and run it during OnCollisionEnter.

It seems fairly likely you didn’t write that code if you don’t know that. I mean if you did great, its just wierd you’d know how to call mathf.clamp and access the terrain data and not know how to use OnCollisionEnter.

If you didn’t write it and don’t know how to code, there is no copy pasting coding. its not like writing where you can be close enough, if one single solitary letter in a piece of code is wrong it will not run. A misspelling, a missed semicolon, a missed bracket, it will not run. You have to spend a week learning the bare bones basics of coding first.