How to see how much a intvalue has changed

  1. What do you want to achieve? See how much a value has changed and display on a textlabel

  2. What is the issue? I don’t know how to do that

  3. What solutions have you tried so far? I’ve tried looking it up but I couldn’t find anything

Please tell me how to do that or link videos from YouTube that can help!

Here is what I would do,

local startVal = intValue.Value

intValue:GetPropertyChangedSignal("Value"):Connect(function()
print("New Value is " .. tostring(intValue.Value) 
print("Old Value is " .. tostring(startVal)
print("Difference is " .. tostring(intValue.Value - startVal)
end)
1 Like

I agree but @TheGameGod_YT make sure to change the startVal value after you check the difference or the other times the scripts runs it will return a wrong value

2 Likes

Here a suitable way to tackle this problem:

local lastValue = intValue.value;
intValue:GetPropertyChangedSignal("Value"):Connect(function()
    local difference = intValue.value - lastValue;
    print("intValue was changed by"..tostring(difference));
    lastValue = intValue.value;
end)
4 Likes

That would be a simple fix, you just set startVal to the new Value at the end of the function