Lua Accumulator

How do I make so if I hold down a button a value incrases? I don’t mean a = a + 1. I do believe that is called increment.

You could use IN_KEYS and create a simple timer, which increases the value every 0,1 second, or something like that.

What will this be used for? It depends what you want it to do.

[lua]local speed = 5 – increases by 5 every second that the button is held down
local val = 0

hook.Add(“Think”, “Accumulate”, function()
if LocalPlayer():KeyDown(IN_RELOAD) then
val = val + FrameTime()*speed
end
end)[/lua]

Something like this maybe?

Yeah thanks!