I want to translate an object when score changes but it doesn't work

Hello!
I have built a simple score system that gives you a point whenever you fall off-world. I now want to increase the height of my walls by 1 meter everytime this happens. I’ve written the following script:

 function Update() {
    	var OldScore = PointSystem.score;
    	if (PointSystem.score > OldScore) {
    		transform.Translate(0,1,0);}
        }

If I put it like this, the wall doesn’t move because OldScore is always the same as PointSystem.score. However, if I put the defining of var OldScore outside function Update( ) the wall lifts off indefinitely. The solution is probably very logical, but I can’t find it.

Thank you for your help!

And with this?

var OldScore = PointSystem.score;

function Update() {
   if (PointSystem.score > OldScore){
      OldScore = PointSystem.score;
      transform.Translate(0,1,0);
   }
}

var OldScore = PointSystem.score;

function Update() {
       
        if (PointSystem.score > OldScore) 
          RaiseWall();
       
}
function RaiseWall()
{
if (PointSystem.score > OldScore)
{
OldScore = PointSystem.Score;
 transform.Translate(0,1,0);}
}

//super simple example