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