Hp Hud

Hey i was Wondering if it was possiple to add like an Text in or above this HuD I found
if Then How.
[Lua]

local smooth = 0

hook.Add(“HUDPaint”, “ColorTest”, function()

local health = math.Clamp(LocalPlayer():Health(), 0, 100)  
smooth = math.Approach(smooth, health, 50*FrameTime())  
  
local red = (1 - smooth/100)^(1/2) * 255  
local grn = (smooth/110)^(1/2) * 255  
local blu = (smooth/200)^2 * 255  
  
local col = Color(red, grn, blu)  
  
local w, h = 60, 200  
local spacing = 32  
  
local equation = (h-8)*(smooth/100)+8  
  
draw.RoundedBox(  
    4,  
    ScrW() - w - spacing - 2,  
    ScrH() - h - spacing - 2,  
    w + 4,  
    h + 4,  
    Color( 30, 30, 30 )  
)  
  
draw.RoundedBox(  
    4,  
    ScrW() - w - spacing,  
    ScrH() - equation - spacing,  
    w,  
    equation,  
    col  
)  

end)

[/Lua]

i have tryed myself but No Luck.

The thing is that i want an Text That’s Like “HP” Above The Hud


(User was banned for this post ("Wrong section" - mahalis))

Sure, the easiest way to draw text is with draw.SimpleText. In your case I’d try something like

[lua]
draw.SimpleText (
“Health:”, --text
“Trebuchet20”, --font
ScrW()-spacing, --x-coordinate
ScrH()-spacing, --y-coordinate
Color(255,255,255,255), --colour
TEXT_ALIGN_LEFT, --x-alignment
TEXT_ALIGN_BOTTOM --y-alignment
)

–I typed it like this to mimic what you did with draw.RoundedBox, this of course is just as valid:
draw.SimpleText (“Health:”, “Trebuchet20”, ScrW()-spacing, ScrH()-spacing, Color(255,255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_BOTTOM)
[/lua]

You can find a list of the default fonts and examples of their appearance here

The Wiki page on draw.SimpleText has the different values for the x and y alignment.

But Where do i put it?
in the end of the script?

[editline]08:04PM[/editline]

thanks i test it ouT<3

Anywhere after your calculations, since it makes references to spacing, and it makes more sense to read if all the actual drawing functions are together.

I gave you a heart because that’s a code snippet I made. <3
But yeah, what MegaJohnny said was right. Also just so you know, I spaced the draw.RoundedBox like that to make it easier to read all of the arguments.

Looks way nicer than a huge string of characters. I sometimes do it if I need to use a giant if line, so you can see each condition nicely.