Hi, I would like to detect how many values are added to an intvalue when it changes, I checked if there was a function for this, but there was none. Does anyone know how to do this?
✓ ANSWER ACCEPTED
How can I detect how many values have been added on an intvalue?
1 answer
✓ Accepted answer
You can do this by having a variable that stores the previous value, and do NewValue - OldValue to get the difference. Here is an example:
local NumberValue = Instance.new("NumberValue")
NumberValue.Value = 10
local OldValue = NumberValue.Value
NumberValue:GetPropertyChangedSignal("Value"):Connect(function() -- check when value changes
local Difference = NumberValue.Value - OldValue -- subtract old from new
print(Difference)
OldValue = NumberValue.Value -- update oldvalue to be new value
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
