HUD: Making a progress bar.

Hey everyone.

I am in the process of making some HUD indication that has to show the progress of a given action.

My aim is basically the same as the lockpick from DarkRP - which has a progress bar as you pick a lock.

My initial thinking was something like this:

function progressBar ()

	local lastTime = CurTime()
	while CurTime()-lastTime < 199 do

hook.Add("HUDPaint", "progress bar HUD element", progressBar)

That, however, doesn’t seem to work. Has anyone got any nice way of doing something like this?

Sorry if you don’t understand my aim here.


  • Puster

That code won’t work because you’re redefining lastTime every time the function is called. You can fix that by placing “local lastTime = CurTime()”, but you’ll probably also want to change the arguments you’re passing to draw.RoundedBox for width.

Thanks, and glory for Cobrastan!