I'm trying to use Derma to make a very simple menu, but when I try to open a panel using the code
[CODE] local plantwinow = vgui.Create("DFrame")
plantwinow:SetSize(202, 102)
plantwinow:Center()
plantwinow:SetTitle("Level " +lvltext +" Plant")
plantwinow:SetDraggable(true)
plantwinow:SetSizable(false)
plantwinow:ShowCloseButton(true)
plantwinow:MakePopup()[/CODE]
but when I run it Gmod says
[CODE]attempt to index global 'vgui' (a nil value)[/CODE]
Does anyone know how to fix this?
Don't run it on the server.
[QUOTE=Wizard of Ass;36682144]Don't run it on the server.[/QUOTE]
I'm currently running it as part of cl_init.lua. It's part of a SENT I'm making.
You are wrong, vgui is always available on the client, check your code.
The only reason why vgui is nil that you either overwrote it run the code on the server.
[QUOTE=Wizard of Ass;36683169]You are wrong, vgui is always available on the client, check your code.
The only reason why vgui is nil that you either overwrote it run the code on the server.[/QUOTE]
Nope. Even outside of the SENT, I tried putting
[CODE]lua_run local plantwindow = vgui.Create(DFrame)[/CODE]
into the Gmod command console during a singleplayer game and it still returned
[CODE][lua_run:1] attempt to index global 'vgui' (a nil value)[/CODE]
so that doesn't seem to work.
[QUOTE=Lee Dumber;36683428]Nope. Even outside of the SENT, I tried putting
[CODE]lua_run local plantwindow = vgui.Create(DFrame)[/CODE]
into the Gmod command console during a singleplayer game and it still returned
[CODE][lua_run:1] attempt to index global 'vgui' (a nil value)[/CODE]
so that doesn't seem to work.[/QUOTE]
Once again you're running it serverside.
lua_run_cl not lua_run
[lua]
local plantwinow = vgui.Create("DFrame")
plantwinow:SetSize(202, 102)
plantwinow:Center()
plantwinow:SetTitle("Level " +lvltext +" Plant")
plantwinow:SetDraggable(true)
plantwinow:SetSizable(false)
plantwinow:ShowCloseButton(true)
plantwinow:MakePopup()
if (SERVER) then print("Running on server!") end
if (CLIENT) then print("Running on client!") e
[/lua]
Run that OP alongside your original code, and it'll tell you whether or not it's being run in the server too.
If it doesn't show that it's running on the server, and vgui still returns nil, make sure you haven't got any other addons fucking it up.
I looked into it using the
[CODE]if (SERVER) then print("Running on server!") end
if (CLIENT) then print("Running on client!") end[/CODE]
method and it turned out that an addon was messing it up. Thanks to everyone for helping me figure out what it was!
Sorry, you need to Log In to post a reply to this thread.