Check when closest to 0

The point of my game is to be as close to 0 as possible. How can I set highscore based on how close you are to 0. Let’s say the last highscore is 0.12, then I get 0.09, then that should be the new high score. Then let’s say I get -0.02, than that’s the new highscore. I know how to use get and set int/float, so that’s not what i’m asking. I’d really appreciate answers!

There is not enough information here to really be able to help you a whole lot. Do you want something like:

if (Mathf.Abs(newScore) < Mathf.Abs(highscore)) highscore = newScore;

This checks the absolute value of the new score and compares it’s total distance from zero to the current highscore’s.

You can use absolute value to normalize the values then take the lowest one.

if(Mathf.Abs(score) < Mathf.Abs(highscore))
   highscore = score;