Error: attempt to index global 'surface' (a nil value)
4 replies, posted
I honestly have no idea what the hell this is supposed to mean, I have a hard time trying to understand certain things and its really damn annoying.
Error output:
[ERROR] addons/unit/lua/autorun/hook.lua:1: attempt to index global 'surface' (a nil value)
1. unknown - addons/unit/lua/autorun/hook.lua:1
surface.CreateFont( "ArialFont", {
font = "Arial",
extended = false,
size = 20,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
hook.Add("HUDPaint", "DrawMyHud", function()
local hp = LocalPlayer():Health()
draw.RoundedBox(0,20,20,510,60,Color(165,165,165))
draw.RoundedBox(0,25,25,hp * 5,50,Color(255,80,80))
draw.SimpleText(hp.."%","ArialFont,250,40,Color(255,255,255),0,0)
end)
fucking autism >:(
Make sure you're running this on client and not server.
Your draw.SimpleText is also wrong, you're missing an endquote to "ArialFont".
Otherwise fixing that simple missing quote made it run fine for me, running it clientside.
Already noticed the missing end quote and fixed it however that did not fix anything
I'm also running it on the client
Strange.
Maybe you have some sort of strange addon that's conflicting with surface.CreateFont somehow?
It's not erroring at all for me while I'm on my own server running it on myself, the health bar draws and works as intended.
Note I'm running it through a Lua editor in-game, not as a file put on the server.
I had conflicted with 2 addons, I have disabled them but this error still occurs?
Sorry, you need to Log In to post a reply to this thread.