[Help] attempt to index global 'vgui' (a nil value)
8 replies, posted
if message == "net" and (CLIENT) then
local frame = vgui.Create("DFrame")
frame:SetSize(400,400)
frame:SetVisible(true)
frame:Center()
frame:MakePopup()
local btn = vgui.Create("DButton",frame)
btn.DoClick = function()
print("Hey!")
print("Processing")
net.Start("Messages")
net.SendToServer()
frame.Destroy()
end end
( I don't know why the code is so glitchy)
Yes, I am using cl_init.lua
And yes, I'm running from client.
The script is running on the serverside. The vgui library does not exist serverside.
It returns table : and some numbers.
It's running on both, or it's running before the vgui library has loaded. When does this script run?
Whether or not if it's running on both, it says explicitly "if CLIENT then"
if SERVER then AddCSLuaFile() return end
Put this at the top of the script. You're running vgui on the server .. and it only works on the client.
On top of that you need AddCSLuaFile on the serverside .. so clients download the script.
That doesn't answer when the file is running
Sorry, you need to Log In to post a reply to this thread.