Mana regeneration

Hey, so I have Mana in my game, and I want it to regenerate, I want it to regenerate slowly like 10 per second and only regenerate if mana has not been used (removed) in the past 5 seconds.
Any ideas how?
Thanks!

What’s a Mana?

text text text text

Runservice is ideal for this situation.

local RunService = game:GetService("RunService")
 
local RATE_PER_SECOND = 2
 
local manarestore = RunService.Heartbeat:Connect(function(step)
	local increment = RATE_PER_SECOND * step
mana.Value + = increment
end)
--to disable
manarestore:Disconnect()

Similar to resetting a combo timer:

manarestore:Disconnect() will be used when the player uses mana ?

Yes in order to disable mana regeneration as you mentioned.

Could I possibly make a modulescript for taking mana, and that ModuleScript will make a value DontRegen and if that value is true, it will not regen and if it’s false, it will regen?
Would that be good?