attempt to index global 'vgui' (a nil value)

Why? Code taken from gmod wiki.




	function Test() //Sweet function name huh?
	local window = vgui.Create( DFrame ) //creates it
	window:SetPos( 1,1 ) // Sets the position
	window:SetSize( 1024, 768 ) // Sets the size
	window:SetTitle( "Radio" ) // Sets the title with my steam username if ya need help
	window:SetVisible( true ) // Yes its visible
	window:SetDraggable( true ) // Allows it to be draggable
	window:ShowCloseButton( true ) // Shows the little x button at top
	window:MakePopup() //Uhh? self explanitory? ... makes it popup
 
	local button2 = vgui.Create( DButton, window ) //Creates button
	button2:SetText( Hide ) //Sets text to hide
	button2.DoClick = function()  //on click sets window invisible
		window:SetVisible( false ) //Window is visible? nahh
		local button3 = vgui.Create( DButton ) //Creates button 3
		button3:SetText( Show ) //Sets button 3's text to Show
		button3.DoClick = function() //runs function on click
			window:SetVisible( true ) // window is visible
			button3:SetVisible( false ) //button 3 is invisible
		end //ends
		button3:SetSize( 200, 20 ) //Sets size
		button3:SetPos( 1,1 ) //Sets button3 position
	end //Ends
	button2:SetSize( 200, 20 ) //Sets Size
	button2:SetPos( 1,25 ) //Creates Button
 
	local RadioThingy = vgui.Create( HTML, window ) //Creates window
	RadioThingy:SetSize(ScrW() - 100, ScrH() - 100) //Sets Size
	RadioThingy:SetPos( 0, 50 ) //Sets position
	RadioThingy:OpenURL( www.google.com ) //Opens this URL in VGui
end // end it
concommand.Add( "radio", Test) // Console Command


you’re running it serverside.

Is the code accidentally running on the server as well as the client?

Also all those text arguments in the functions need quotes around them.

Use: “lua_openscript_cl”

Not: “lua_openscript”