Error: attempt to index global 'vgui' (a nil value)
3 replies, posted
I keep running into this error when I am working with derma. I'm trying to open a derma panel when a player presses f1.
Error in the console: [ERROR] gamemodes/benstdm/gamemode/teamselect.lua:2: attempt to index global 'vgui' (a nil value)
1. unknown - gamemodes/benstdm/gamemode/teamselect.lua:2
2. unknown - lua/includes/modules/concommand.lua:54
init.lua:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
AddCSLuaFile("teamselect.lua")
include("shared.lua")
include("teamselect.lua")
-- VGUI CONTROL --
function GM:ShowHelp( ply ) -- F1
ply:ConCommand( "teamSelect" ) --cl_menus.lua
end
teamselect.lua
function teamSelect( ply )
local Frame = vgui.Create( "DFrame" )
Frame:SetSize(1024,600)
Frame:Center()
Frame:SetVisible( true )
Frame:SetDraggable( false )
Frame:ShowCloseButton( true )
Frame:MakePopup()
Frame.Paint = function(s, w, h)
draw.RoundedBox(5,0,0,w , h,Color(50,50,50,10))
end
local plyName = LocalPlayer():Name()
local DLabel = vgui.Create( "DLabel", Frame )
DLabel:SetWide(1024)
DLabel:SetHeight(100)
DLabel:AlignTop()
DLabel:SetContentAlignment(5)
DLabel:SetText( "Welcome ".. plyName .."!")
DLabel:SetTextColor(Color(255,255,255))
DLabel:SetFont("DermaLarge")
local TeamText = vgui.Create("DLabel", Frame)
TeamText:SetWide(1024)
TeamText:SetHeight(200)
TeamText:SetContentAlignment(5)
TeamText:SetText("Select A Team!")
local USA = vgui.Create("DImageButton",Frame)
USA:SetPos(100,200)
USA:SetWidth(300)
USA:SetHeight(300)
USA:SetContentAlignment(5)
USA:SetImage("USAButton.png")
local RUSSIA = vgui.Create("DImageButton",Frame)
RUSSIA:SetPos(624,200)
RUSSIA:SetWidth(300)
RUSSIA:SetHeight(300)
RUSSIA:SetContentAlignment(5)
RUSSIA:SetImage("Russia.png")
end
Vgui is clientside.
Include teamselect.lua on client, not server
yep fixed it thanks!
Include teamselect from cl_init instead. Keep it AddCSLuaFile'd tho
Sorry, you need to Log In to post a reply to this thread.