I am doing a regeneration system of something that works with an int value but I can only detect when it changes and not when it stops changing, what do I do?
it is like knowing if something is not changed from time to time
I am doing a regeneration system of something that works with an int value but I can only detect when it changes and not when it stops changing, what do I do?
it is like knowing if something is not changed from time to time
Well you can put in a delay after it changes and run code after that if it hasn’t changed again. Something like this
local lastChange = tick()
local changedValue = function()
local thisChange = tick()
lastChange = thisChange
wait(3)
if lastChange == thisChange then
--hasn’t changed in about 3 seconds.
end
end
There are a few ways to do this. You could check to see if Humanoid.Health == Humanoid.MaxHealth then run some code. Most regeneration scripts have a set regeneration time if the person’s health doesn’t change in this time then run some code.
local intValue = workspace.IntValue
local lastChanged = tick()
intValue.Changed:Connect(function(int)
lastChanged = tick()
task.delay(3, function()
if intValue.Value == int then
--Value hasn't changed.
end
end)
end)