A VGUI error

Before we start, I had a look round FP for this, couldn’t find anything. So I thought I’d ask you folks. :slight_smile:
Now, I bet EVERYONE who has done their first derma panel has seen this error before:


HL2RPGM\gamemode\cl_init.lua:10: attempt to index global "vgui" (a nil value)

Now there’s no error’s on this script apart from that one. There’s no COULDN’T LOAD GAMEMODE! error in the console, so the init file and shared file is fine, I just know it’s the VGUI.

Can anyone tell me where I’m going wrong? Here’s my cl_init.lua:


function mainmenu() --mainmenu function
local mainmenu = vgui.Create( "DFrame" ) --creates menu
mainmenu:SetPos( ScrW() / 2 - 300,  ScrH() / 2 - 300 ) --position of menu (ScrW and ScrH mean Screen Width and Screen Height.)
mainmenu:SetSize( 600, 600 ) --size of menu
mainmenu:SetTitle( "Welcome to "..GetConVar("hostname")..". Please, enjoy your stay." ) --title of menu (top)
mainmenu:SetVisible( true ) --visable?
mainmenu:SetDraggable( false ) --draggable?
mainmenu:ShowCloseButton( true ) --show close button?
mainmenu:MakePopup() --popup?
 
local menutabs = vgui.Create( "DPropertySheet" ) --menutabs
menutabs:SetParent( mainmenu )
menutabs:SetPos( 10, 30 )
menutabs:SetSize( 580, 560 )
 
	local welcomepanel = vgui.Create("DPanel")
	welcomepanel:SetSize( 550, 480 )
	local welcometext = vgui.Create( "DTextEntry" )
	welcometext:SetParent( welcomepanel )
	welcometext:SetPos( 10,50 )
	welcometext:SetTall( 380 )
	welcometext:SetWide( 530 )
	welcometext:SetDrawBackground( false )
	welcometext:SetDrawBorder( false )
	welcometext:SetEditable( false )
	welcometext:SetEnterAllowed( false )
	welcometext:SetMultiline( true )
 
	local text = {}
	text[1] = ( "Welcome to "..GetConVar("hostname").." have fun!
") -- Displays the hostname and other text put there. 
	text[2] = ( "
" ) --"
" means new line
	text[3] = ( "
" )
	text[4] = ( "
" )
	text[5] = ( "
" )
	text[6] = ( "*Please visit JovaCentral.com for more information.*
" )
	text[7] = ( "
" )
	text[8] = ( "
" )
	text[9] = ( "
" )
	text[10] = ( "Rules:
" )
	text[11] = ( "No Racism
" )
	text[12] = ( "No Cussing
" )
	text[13] = ( "No Spam (Mic, Chat, Etc)
" )
	text[14] = ( "
" )
	text[15] = ( "Obey Superiors
" )
	text[16] = ( "If these rules aren't implied, you will be punished." )
 
	    welcometext:SetText(table.concat(text))
 
        menutabs:AddSheet( "Welcome", welcomepanel, "gui/silkicons/exclamation", false, false, "Welcome, please enjoy your stay." )
    end
concommand.Add( "fts_menu", mainmenu )

Thanks guys. Please post if you don’t understand what I’m trying to ask for.

Your running the code on server run in on client instead