I try this:
local number = 0
number.Changed:Connect(function() --error
end)
It doesn't work. Constantly checking via while true is inefficient. How to call an event when a number variable changes? Or can I?
I try this:
local number = 0
number.Changed:Connect(function() --error
end)
It doesn't work. Constantly checking via while true is inefficient. How to call an event when a number variable changes? Or can I?
That will not work. What you can use is a NumberValue or an IntValue and do something when it changes.
local intValue = game:GetService("ReplicatedStorage").someIntValue -- # some int value
intValue.Changed:Connect(function(newValue)
-- # ...
end)
The changed event on ValueBase instances is modified to fire only on the Value property, so you will not need to worry about any :GetPropertyChangedSignal()'s or anything. newValue will be the new value.
Just in whatever event that would change the int value, also insert the code to do whatever it is to be done when the value changes
Yes, if my answer helps out please accept it. It gives us both reputation that we deserve.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
there's no way but what you can do is just call a function when you change it
Don't forget to accept my answer if it helps out.