How to know if NumberValue changed to a bigger or smaller number

Hello,

How would I know if a NumberValue went smaller or bigger? I know I can use :GetPropertyChangedSignal(“Value”) but that does not tell me if the Value got bigger or smaller.

I don’t know what other informations to provide, sorry.

Thanks!

2 Likes

Idk maybe do this:

local startingValue = YourNumberValue

YourNumberValue:GetPropertyChangedSignal(“Value”):Connect(function()
    if YourNumberValue.Value > startingValue.Value then -- the new value is greater than the starting value
        --bigger
    elseif YourNumberValue.Value < startingValue.Value then -- the new value is smaller than the starting value
        --smaller
    end
end)
3 Likes

something like this

local numberValue = -- where the number value is located
local value = numberValue.Value

NumberValue.Changed:Connect(function(newValue)
    if newValue > value then
        -- It is bigger
    elseif newValue < value then
        -- It is smaller
    else
        -- No change
    end
    value = newValue -- updates the value
end)
3 Likes

I will give it a shot
@IAmPinleon @Scripted_Vortex

1 Like

This won’t work, since .Changed goes for all properties so newValue won’t be a value…

Values have a modified changed event that only detects the Value being changed since it’s the only useful property

1 Like