Hi. I am trying to write a regen system but I can’t figure out how to do it. I want the value to start regenerating if it doesn’t decrease for 3 seconds. Using :GetPropertyChangedSignal(). Can anyone give me some tips?
Ey
You can try somrthing like
local lastRun = 0
local function regen()
if tick() - lastRun > 3 then
proceed end
lastRun = tick
task.delay(3, function()
if someValueThatChecksIfXDidntDecreaseFor3Seconds then return end
-- your code
end)
local signal = instance:GetPropertyChangedSignal()
local stamp = 0
signal:Connect(function()
stamp = os.clock()
end)
-- later on in your business logic..
if os.clock() - stamp < 3 then
-- regen
end