3D Health bar scaling down when Object A Hits object B Health Bar Object C. hit?

Ok so i have a boss with week points that flash when you shoot them and a health code of 1000 and 1 gets taken off every time u hit
a week point.

now i have a 3D object as a health bar that I want to scale down on the X AXIS by 1 when u hit a week point.

on hit:

/////
var colors = new Color[2];

function OnCollisionEnter() {

renderer.material.color = colors[0];
yield WaitForSeconds(0.1);
renderer.material.color = colors[1];

CoreSpawHealth.CoreHealth += -1;

}
//////

thinking of adding a var “when hit : int = 10000” and call it by another script on the enemy health bar cube and when it detects 1 being taken of health it shrinks. but haven’t been able to do this been at it for 3 hours now.

////WORKING WITH JAVA///

First of all this is not Java. Either you call it Javascript or Unityscript.
I’m not sure I understand you but I’ll try to answer anyways. When you want to scale down the GameObject which the script belongs to it’s pretty simple just add the following line:

transform.localScale += Vector3(-(CoreSpawHealth.CoreHealth / 1000),0,0);