Is there a way to "invert" numbers?

I want to know how to invert numbers. And i dont mean 10 turns into -10, im something else.
What i mean is lets say the “middle” number is 50, and the “Current” number is 50. If i change the current number to 49, i want to get 51. so 40 would become 60, 10 would be 90, ect. How can i do this?

Im tryign to do this because i want to make a blur effect more visible depeding on how low the players health is.

1 Like

All you need to do is “MaxNumber - Number”.
(MaxNumber is probably 100 in this case, so:

100 - 10 = 90
100 - 49 = 51
100 - 27 = 73)

This might not be the most practical way but it’s the only way I can think of and see online. If this isn’t what you were thinking of then let me know, I hope it helps though! :smiley:

4 Likes

Or using a middle number:

local function Invert(Number, MiddleNumber)
    return MiddleNumber -(Number - MiddleNumber);
end
2 Likes

Math magic.

middle = 50
current = 49

inverted = middle * 2 - current

print(inverted) 
1 Like