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

Checking how much an IntValue has .Changed by?

I can work out how to check for the change easily enough,

IntValue.Changed:connect(function()

end)

But is there anyway to find out the amount it has changed by?

2 answers

local IntValue = IntValue --make this = to your IntValue
local last = IntValue.Value --gets the start value
local changeamount = 0 --how much it changes

IntValue.Changed:connect(function()
changeamount = IntValue.Value - last --the difference
last = IntValue.Value --redoes last value
end)

This is just a slight change to sporkyz as it gets the absolute value of the change, which you might or might not want.

local IntValue = Instance.new('IntValue', script) --make this = to your IntValue
local last = IntValue.Value --gets the start value
local changeamount = 0 --how much it changes

IntValue.Changed:connect(function()
changeamount = math.abs(IntValue.Value - last) --[[the difference + gets the change 
	disregarding the negative as you might want.
--]]

last = IntValue.Value --redoes last value
print(changeamount)
end)

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