After Effects Expressions – Stopping CurrentTime at needed moment or frame

I need my
linear(time, starttime, starttime+duration, key1.value key2.value)
work when it triggers by if.
Problem is i cant attach start time to start frame of if() condition.

How i catch elapsed time minimal value and stop it from changing?
For example if my if() triggers at 50 frame how i can catch this value of 50 and stop it? Because everything i tried before is keep.

I have one parent layer. There is opacity change from 0 to 100 just for triggering if() when opacity is over 50.

And i have rotation parent keys. I want set parent keys one time and make other layers rotate like it parent keys when if() works.

 `var keykey1 = thisComp.layer("Parent control layer").transform.opacity.key(1);
 var keykey2 = thisComp.layer("Parent control layer").transform.opacity.key(2);
 var kr1 = thisComp.layer("Parent control layer").transform.rotation.key(1);
 var kr2 = thisComp.layer("Parent control layer").transform.rotation.key(2);
 var N = thisComp.layer("Parent control layer").transform.opacity;
 var dlit = kr2.time - kr1.time;
 var startTime = (N > 50 && typeof startTime === 'undefined') ? time : 1;
 var elapsedTime = (N > 50) ? time - startTime : 0;
 var currentTime = time;
 var pya = 6;
 var endt= pya+dlit;



 if ( N > 50) {
value=linear(time, pya, endt, kr1.value, kr2.value);
}`
 

I’ve tried math.min and chat gpt but this dont work.