How to make a number get closer to 0 the higher another value gets

Hello! I am currently trying to make a system where if you stay in one area for too long, a value slowly goes up, and I want a gui to slowly become more and more visible the higher that value is.

My first thought would just be to divide the value by 100 so that it gets closer to 0, but that doesn’t work because now the gui is completely visible and becomes less visible as time goes on, when it should be the opposite.

Keep in mind, the value is a negative, so while you are in a certain area, the value becomes lesser and lesser (eg. -20,-30,-40). I want an ImageLabel to become more and more visible the higher(really just lower, further into the negatives) the number gets.

You can use math.abs(negativeNumber) and it will give you the positive version of it

Thank you, I will use this in the future, but this doesn’t really answer the question

ohh I misread this, sorry for the misunderstanding

try this

function getVisibility()
	if **your value** < 0 then
		local visibility = 1 - math.abs(**your value**)/100
		return visibility
	else
		return 1
	end
end
6 Likes

Thanks a bunch, you just solved a big problem for me :slight_smile:

1 Like