1
votes

When trying to run the code below, this error is produced:

lua/testhud.lua:28: ')' expected (to close '(' at line 19) near ''

Code:

surface.CreateFont( "Whatever", {

    font = "Arial", 
    size = 100,
    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 health = LocalPlayer():Health()

    draw.RoundedBox(0,8,8,300+4 , 30+4,Color(86,55,89))
    draw.RoundedBox(0,10,10,health * 3,30,Color(255,120,120))
    draw.SimpleText(health.."%","Whatever",10 + 150 , 10 + 15 ,Colour(255,255,255),1,1)


end
1
This is a fairly easy to interpret error. Parenthesis should be matched. For every opening paren, there should be a closing paren. The error tells you Lua expected to find a closing paren and didn't, and it tells you exactly where the opening paren was (line 19). So you go to line 19, find an opening paren, then try to find the closing one that matches it. Doing this will lead you to Chris H's answer. - Mud

1 Answers

3
votes

Error: lua/testhud.lua:28: ')' expected (to close '(' at line 19) near ''

You are missing a ')' to close the '(' near the start of line 19. Presumably it should be after the 'end' statement of the function you're defining:

hook.Add( "HudPaint" , "DrawMyHud" , function() 

    local health = LocalPlayer():Health()

    draw.RoundedBox(0,8,8,300+4 , 30+4,Color(86,55,89))
    draw.RoundedBox(0,10,10,health * 3,30,Color(255,120,120))
    draw.SimpleText(health.."%","Whatever",10 + 150 , 10 + 15 ,Colour(255,255,255),1,1)

end )