Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i detect if a number value increases or decreases?

I want to check if a number value changed but i also want to check if it went up or down.

SUNMASS.Changed:Connect(function()
	if (SUNMASS.Value + (DEFAULTRADIUS - 1)) > DEFAULTRADIUS then
		local differance = (SUNMASS.Value + (DEFAULTRADIUS - 1)) - DEFAULTRADIUS
		RADIUS.Value = RADIUS.Value + differance
	end
	wait(0.5)
end)
	

1 comment

0

https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed it is a link to the changed event, I had a brief look at it so I don’t know too much about it but it has 1 parameter

2 answers

local sv = SUNMASS
SUNMASS.Changed:Connect(function()
	if SUNMASS > sv then
		print("decreases")
	elseif SUNMASS < sv then
		print("increases")
	end
end)

hi, back here! I figured it out. So we have to use a small formula that subtracts the changes value from the new value.

So likes this:

local function valueChanged(num)
     local determinatial = SUNMASS.Value - num

      if SUNMASS.Value < determinatial then
            return “bigger”
      else
            return “smaller”
      end
end

SUNMASS.Changed:Connect(valueChanged)

This discussion is preserved as it was. New answers, comments, and votes are closed.