Derma Error - attempt to index global 'vgui' (a nil value)
8 replies, posted
[CODE]local function startingscreen()
--// Main Frame Start
local MainFrame = vgui.Create( "DFrame" )
MainFrame:SetSize( 250, 1200 )
MainFrame:SetPos( 0, -50 )
MainFrame:SetTitle("MyGamemode")
MainFrame:SetVisible( true )
MainFrame:SetDraggable( false )
MainFrame:ShowCloseButton( false )
MainFrame:MakePopup()
MainFrame.Paint = function()
draw.RoundedBox( 0, 0, 0, MainFrame:GetWide(), MainFrame:GetTall(), Color( 0, 0, 0, 255) )
end
--// Main Frame End
--// Carbons Backgrounds Start
--// Carbons Backgrounds End
--// Spawn Button Start
local SButton = vgui.Create( "DButton" )
SButton:SetParent( MainFrame )
SButton:SetText( "Agree to the rules and Spawn" )
SButton:SetPos( 2, 716 )
SButton:SetSize( 246, 50 )
SButton.DoClick = function ()
MainFrame:Remove()
end
--// Spawn Button End
end
concommand.Add( "startmenu", startingscreen )
THE ERRROR OF THE ERRORS, This happenes when i write "startscreen" in console:
] startmenu
[ERROR] gamemodes/privateer/gamemode/cl_start.lua:8: attempt to index global 'vgui' (a nil value)
1. unknown - gamemodes/mygamemode/gamemode/cl_start.lua:8
2. unknown - lua/includes/modules/concommand.lua:69[/CODE]
You're running the file serverside.
[QUOTE=ms333;42284544]You're running the file serverside.[/QUOTE]
I am a "noob" in lua, what does that mean :P
Google "Gmod Clientside" and "Gmod Serverside".
[QUOTE=Koolaidmini;42284646]Google "Gmod Clientside" and "Gmod Serverside".[/QUOTE]
As i said i don't know LUA, I just searched it and i got much stuff i don't even understand...
Move the function to some clientside file and do some networking and/or just add "if SERVER then return end" at top of it.
There is the server, which deals as expected on the server, and the client, which means what's run on your computer. This all gets confusing when in single player, but it's simple actually. Basicly, you file is being included by an init.lua file in your gamemode I'm guessing. Instead, include it in the cl_init.lua and make sure to AddCSLuaFile the file from the init.lua
[QUOTE=James xX;42284901]There is the server, which deals as expected on the server, and the client, which means what's run on your computer. This all gets confusing when in single player, but it's simple actually. Basicly, you file is being included by an init.lua file in your gamemode I'm guessing. Instead, include it in the cl_init.lua and make sure to AddCSLuaFile the file from the init.lua[/QUOTE]
Wow dude, finally someone who can explain something to a newbie :P Thanks alot it helped, I just Removed include("cl_start.lua") from init.lua and added it to cl_init.lua, I keeped the AddCSLuaFile in Init.lua and it works :D
Mark as solved?
Sorry, you need to Log In to post a reply to this thread.