• attempt to index global 'vgui' (a nil value)
    4 replies, posted
I've been trying to get this script to run for ages. I've found many solutions to my problem but none of them worked for my script. Here's the problem, when I try to execute my script it shows this error: [code]autorun/cl_init.lua:4: attempt to index global 'vgui' (a nil value)[/code] According to most threads I have to execute the function as a clientside function so I put the function inside cl_init.lua for testing purposes. I'm kinda lost here. cl_init.lua[lua]function menuAniCator( ) Msg( "Trying to initialize AniCator's Specials | Main Menu ...\n" ) local frame = vgui.Create( "Frame" ) frame:setName( "AniCator's Specials | Main Menu" ) end concommand.Add("menuAniCator", menuAniCator)[/lua] Kind regards,
It doesn't matter what the file is called if you place it in lua/autorun. Move the file to autorun/client.
I have moved the cl_init.lua script to autorun/client and the init.lua to autorun/server. I have slightly modified the init.lua file so it'll properly load the cl_init.lua file. The script still doesn't execute though.
[QUOTE=AniCator;19681198]I have slightly modified the init.lua file so it'll properly load the cl_init.lua file.[/QUOTE] Properly load in what way? It will get executed automatically.
Well. It didn't do it properly before I changed the init.lua file. Unless I'm really doing something wrong. When I hadn't changed the init.lua file yet it displayed 'Unknown Command: menuAniCator'. init.lua[lua]AddCSLuaFile ("cl_init.lua") include ('autorun/client/cl_init.lua')[/lua]Thanks for helping me so far. [editline]01:57PM[/editline] I have managed to fix it by deleting the include line in the init.lua file. It was including the file server side and vgui doesn't work server side. Thanks for your help Nevec. :)
Sorry, you need to Log In to post a reply to this thread.