Changing text color according to variable

I need to change text.color from green to red as a variable approaches it’s max. Is there any way to do this?

This is how it works (Keep in mind this only works for dynamic Fonts):