Clientside Derma Menu Start Up Issues

Hi, currently working on a Derma Menu for GMod.

Here is my script for the main window


local frame = vgui.Create("DFrame")
frame:SetSize(500,500)
frame:SetPos(12,12)
frame:SetVisible(false)
frame:MakePopup()
frame:SetTitle("AutoULXCleaner - Derma Test Window")
frame:ShowCloseButton(false)
frame.Paint = function(s , w , h)

	draw.RoundedBox(5,0,0,w , h,Color(91,155,9))

end


So the problem is when the client is loading, for some reason it’s giving this error while the client is still loading


[H4MZ4|3|STEAM_0:1:93571240] Lua Error:

[ERROR] addons/autoulxcleaner/lua/autorun/client/cl_timerscript.lua:5: attempt to index local 'frame' (a nil value)
  1. unknown - addons/autoulxcleaner/lua/autorun/client/cl_timerscript.lua:5
   2. include - [C]:-1
    3. unknown - addons/autoulxcleaner/lua/autorun/autoload.lua:8


[H4MZ4|3|STEAM_0:1:93571240] Lua Error:

[ERROR] addons/autoulxcleaner/lua/autorun/client/cl_timerscript.lua:5: attempt to index local 'frame' (a nil value)
  1. unknown - addons/autoulxcleaner/lua/autorun/client/cl_timerscript.lua:5

However once the client is loaded up fully into the game, and I force it to load the script again, it works perfectly.

I’m assuming the derma menu is loading to early. I am guessing it needs something that will make the script load up once the client is fully connected, which I am not sure how to do?

Show us cl_timerscript.lua and autoload.lua

cl_timerscript.lua - http://pastebin.com/MA5iiSmh

autoload.lua - http://pastebin.com/x92FyYkQ

The first line of cl_timerscript.lua makes no sense. That’s not how hook.Add works, you can simply remove it, and instead of using SetVisible to open the DFrame, create it inside a function (lines 4-93 should all be inside a function, the one that gets called when you use the AutoULXMenu concommand).

As for the OnSelect function - Instead of having so many net messages, you can have 1 net message (e.g. “dropdownis”), and use

net.WriteInt &

net.ReadInt to know what the number is

(Side note) You can simply use AddCSLuaFile oustide of the if statements, or just not run it on the client - As it does nothing on the client

Using net to send over the value wasn’t working very well and resulted in different values, sometimes being 0, sometimes being correct but using that value in the timer.Adjust script on the server side wasn’t working at all. So I gave up on it. Plus it’s easier to manage it with separate if statements for each option, although bad because it makes the script messy.

I’m pretty new to Lua and this is the first real addon I am making that includes a menu and stuff so excuse my bad knowledge on it.

Regarding the SetVisable, it seemed like the easiest way to deal with it, though I would’ve though it would be hidden and loaded in the background all the time but it was the easiest way I knew of.

Though it’s always great to learn new things, and learning that it would be better to have it load under a function is good because it solves the though of it always being loaded.

So I will try it now. Thanks

Can you show us how exactly you were using net library to send values? Because it sound to me like you were doing something incorrectly.