On-Screen Text Crashing Help


I’ve been trying to create some sort of health bar system, a small GUI of sorts. I have most the shapes done and all in place, I just need some text within those boxes. The problem is that when I use the code below my game will crash randomly, straight to desktop, with no errors what so ever after a few minutes. I have tried for hours now to figure out what the error is, but no luck.

surface.CreateFont( "NewText",         {
        font = "HudSelectionText",
        size = 13,
        weight = 500,
        blursize = 0,
        scanlines = 0,
        antialias = true,
        underline = false,
        italic = false,
        strikeout = false,
        symbol = false,
        rotary = false,
        shadow = false,
        additive = false,
        outline = false,
        } )    
    surface.SetTextPos(130,785,ScrH() - 100)

Maybe one of you could shed some light on this situation.


Create the font outside of your rendering function, also you’ll need to use surface.SetFont to use your font at all.

Thanks so much! I can finally get further with what I was working on!