[Closed]Help with Script for Terrain deforming

I hav this Javascript Script:

private var tData : TerrainData;
private var saved : float[,];

    public var explosion : GameObject;
    var countdown :float;
    var cratertex : Texture2D;
    var xRes;
    var yRes;
    var craterData;
    var xkoordinate :int;
    var zkoordinate :int;
    var explkoordinate :Vector3;
    public var Spieler :GameObject;
    
    function Start () {
    	countdown=1;
    	explkoordinate=  new Vector3(0,0,0);
    	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 () 
    {	countdown-=Time.deltaTime;
    	if (countdown<0&&Spieler!=null)
    		{
    			zkoordinate = Random.Range(Spieler.transform.position.z, Spieler.transform.position.z);
    			xkoordinate= Random.Range(Spieler.transform.position.x, Spieler.transform.position.x);
    			
    			var x : int = Mathf.Lerp(0, xRes, Mathf.InverseLerp(0, tData.size.x,Spieler.transform.position.x));
    			var z : int = Mathf.Lerp(0, yRes, Mathf.InverseLerp(0, tData.size.z,Spieler.transform.position.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);
    		explkoordinate=  new Vector3(xkoordinate,cratertex.height+10,zkoordinate);	
    		Instantiate (explosion, explkoordinate, Quaternion.identity);
    		countdown =1;
    	}
    }

It will make a Pan every Second in the Terrain where the Player stands and instantiates an Explosion.Everxthing works,but if i make the terrain bigger, also the pan gets bigger.How do i make it that the pan does not get bigger with bigger Terrain?

Sorry for my English.

My guess is that because you’re setting you xRes and yRes variables from the heightmap(which is being generated from the terrain?) that’s causing your numbers here:

x = Mathf.Clamp(x, cratertex.width/2, xRes-cratertex.width/2);
z = Mathf.Clamp(z, cratertex.height/2, yRes-cratertex.height/2);

to change with the scale/size of the terrain. That’s my best guess from the info provided anyway.