Fonts & nil values

Hello

So I was just creating a simple dpanel with a button. However when I set the font of my dbutton, I’m presented with a lua error. I can’t work out what’s causing it, I’m certain that’s how I’ve always set my fonts.

Lua error:

[ERROR] addons/new_ulx/lua/autorun/client/cl_nulx.lua:29: attempt to call method ‘SetFont’ (a nil value)

  1. Function - addons/new_ulx/lua/autorun/client/cl_nulx.lua:29
  2. unknown - lua/includes/modules/usermessage.lua:87

Code:
[LUA]
AddCSLuaFile()

local baseColor = Color( 18, 18, 18, 255 )

surface.CreateFont( “sButtons”, {
font = “Trebuchet24”,
size = 15,
weight = 0,
antialias = true,
} )

if CLIENT then
usermessage.Hook( “nulxOpen”, function()
// Initial base do not touch
local base = vgui.Create( ‘DPanel’ )
base:SetSize( 400, 500 )
base:Center()
base:SetPos( (ScrW()/2)-(base:GetWide()/2), (ScrH()/2)-(base:GetTall()/2)-ScrH() )
base:MoveTo((ScrW()/2)-(base:GetWide()/2), (ScrH()/2)-(base:GetTall()/2), 0.5,0,-1)
base:MakePopup()
base:SetVisible( true )
function base:Paint( w, h )
draw.RoundedBox( 0, 0, 0, w, h, baseColor )
end
// Close button do not touch
local close = vgui.Create( ‘DPanel’ )
close:SetSize( 75, 25 )
close:SetPos( 325, 0 )
close:SetFont( “sButtons” )
close:SetTextColor( Color( 255, 255, 255, 255 ) )
close:SetText( “CLOSE” )
close.DoClick = function()
base:SetVisible( false )
end
end )
end
[/LUA]

Any help would be awesome!

Thanks.

Hope it isn’t a noob mistake, but it’s the same as my others and they work.

NOTE: The font is a default font for gmod.

You need to change the class from a DPanel; the DPanel does not have that method available. Try setting close to a DButton instead.

Ohh, as I said. It was a noob mistake, It was supposed to be a button :confused:

Sorry for wasting time, I should have been more careful.