Help With table expected, got user data

EDIT:
I gave up on this and completely restructured to to be in a function that i can call instead e.g



function MakeJoinScreen()
    local frame = vgui.Create("DFrame")
    frame:SetSize(ScrW(),ScrH())

    local booturn = vgui.Create("DButton", frame)
end


You get the idea…

So now when the netmsg is received i just do something like:
(in a client file ofc)



net.Receive("dothatguithing", function()
    MakeJoinScreen()
end)


Thanks for your help tho guys!

END OF EDIT -----------------------------------------------------------

Hi there, so im working on a gm and I came across and error

There error is:



[ERROR] lua/includes/extensions/table.lua:75: bad argument #1 to 'pairs' (table expected, got userdata)
  1. pairs - [C]:-1
   2. Merge - lua/includes/extensions/table.lua:75
    3. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:31
     4. func - gamemodes/secwet/gamemode/client/cl_guihandler.lua:9
      5. unknown - lua/includes/extensions/net.lua:32


I have done some research and to no avail, and am still curious as to what is causing it. There are two functions very similar and the first one throws an error and works. The second one throws and error and doesnt work.

The code is:




net.Receive( "makegui", function(len, ply)
	local Gui = net.ReadString()
	local makeme = vgui.Create(Gui)
	makeme:SetVisible(true)
end )

net.Receive( "delgui", function(len, ply)
	local AGui = net.ReadString()
	local closeme = vgui.Create(AGui)
	closeme:SetVisible(false)
	closeme:Close()
end )


These NetMsgs are defined here:



function OpenGUI(ply, Gui) -- Creates a gui with arguements of which player to make it for and which gui to make
	if !ply then return end
	if !Gui then return end
	local Gui = tostring(Gui)

	util.AddNetworkString( "makegui" )
	net.Start( "makegui" )
	net.WriteString(Gui)
	net.Send(ply)

end

function CloseGUI(ply, Gui) -- Creates a gui with arguements of which player to make it for and which gui to make
	if !ply then return end
	if !Gui then return end
	local Gui = tostring(Gui)

	util.AddNetworkString( "delgui" )
	net.Start( "delgui" )
	net.WriteString(Gui)
	net.Send(ply)

end


Any help is appreciated,
Thanks

“local closeme = vgui.Create(AGui)”

Take a look here (http://wiki.garrysmod.com/page/vgui/Create) and you’ll see you’re trying to create a vgui element using an already existing vgui element as the new one’s classname.

Ahhh i see! thanks. So i have to remove the existing vgui element before creating another one.

you cannot simply send a gui over a whole netmessage as string (Especially since netmessages are limited in length) simply send a net message to the player (empty message though), then open the desired panel.

They’re sending the name of it as far as I can see.

As for the error in question at the top, it seems someone called vgui.Register with userdata of some kind instead of the panels meta table. What is the panel name you’re sending over the net message?