Derma problem

autorun/server/cl_commandline.lua:2: attempt to index global ‘vgui’ (a nil value)

That is the error… Here is the entire file…


 function commandline()
	commandinput = vgui.Create( "DFrame" )
	commandinput:SetSize( 220, 100 )
	commandinput:SetPos( 10, 40 )
	commandinput:SetTitle( "Direct Commandline" )
	commandinput:SetDraggable( true )
	commandinput:ShowCloseButton( true )
	commandinput:MakePopup()

	local CommandLabel = vgui.Create( "DLabel", commandinput )
	CommandLabel:SetSize( 30, 25 )
	CommandLabel:SetPos( 10, 20 )
	CommandLabel:SetText( "Command Input " )

	local commandTextEntry = vgui.Create( "DTextEntry", commandinput )
	commandTextEntry:SetSize( 100, 25 )
	commandTextEntry:SetPos( 10, 40 )
	commandTextEntry:SetText( "" )
	
	local ApplyButton = vgui.Create( "DButton", commandinput )
	ApplyButton:SetText( "Execute" )
	ApplyButton:SetPos( 15, 70 )
	ApplyButton.DoClick = function()
	if( commandTextEntry:GetValue() == "" ) then
		LocalPlayer():PrintChat( "No command was input.", false )
		return
	else
		LocalPlayer():ConCommand( commandTextEntry:GetValue() )
		commandinput:Remove( )
		end
	end
end
concommand.Add( "commandline", commandline) 

I am thinking it is either suppose to go in the autorun/client/ folder or it needs a if (CLIENT) then or a if (SERVER) then etc.

You’re right.

Edit: Lol you have it in /server/ That’s why. The client doesn’t run that. If you want both to run it, put it in autorun/

I know, I did do that, but it is still erroring, wait hold on… Might have solved this.

schumacher, this is something that has been pondering me as well, and I can’t figure it out, if you do, could you tell me? Mabye even post the code? and tell me where you put the .lua file.

this must go in the autorun/client
since derma and HUD functions alre ALL client side function, like why dos the server console need HUD? or maybe an derma frame?

logic^^

but still, and if your not sure, try to put it in a autorun, and put at thge top if SERVER then return end
or replace SERVER shit CLIENT, your call