surface.SetFont( "Trebuchet24" )
local message = "Hello World"
local width, height = surface.GetTextSize( message )
print( "Text width: " .. width .. ", text height: " .. height )
You would put the “name” string into the surface.GetTextSize function. This will return the width and height of the text from the font you use (your font is probably already set if your writing text though). Use these values to determine box size.
-Pro tip, store the screen width/height in variables ( ScrW() , ScrH() ), then also create another variable named something like “screenMin”. Set “screenMin” to whatever screen length is lowest, and use this to construct all your hud elements…just so your hud always looks nice on different resolutions. I then create box’s and such using values like screenMin*0.2