attempt to index local 'frame' (a nil value)

I dunno how to fix this error, it gives me following FULL error:

[ERROR] addons/test2/lua/autorun/cl_init.lua:49: attempt to index local 'frame' (a nil value)
  1. createframe - addons/test2/lua/autorun/cl_init.lua:49
   2. unknown - addons/test2/lua/autorun/cl_init.lua:97

where the DFrame gets created in the “createframe()” function:

local frame = vgui.Create("DFrame")
	frame:SetSize(ScrW() - 100, ScrH() - 100)
	function frame:Paint(w, h)
		draw.RoundedBox(0, 0, 0, w, h, Color(51, 51, 51, 255))
		draw.RoundedBox(0, 0, 0, w, 25, Color(63, 63, 63, 255))

and theres the top of my cl_init.lua, incase you think I include serverside files etc:


if not CLIENT then return end

I dont know what to do :c, I tried it using Gmod “singleplayer” or “listed server”, and the normal “SRCDS Server”, everything gives that error, even though I should be running it clientside? Error color is yellow, therefore its a clientside error, right?

[editline]27th May 2015[/editline]

nvm, somehow it worked, but I use a chatcommand system, like stranded’s(just using garrys example with string.explode()), and somehow it doesn’t automaticly add the chatcommands, I have to add them myself? Like, I have to save the file manually for the commands to be injected in the table

[editline]27th May 2015[/editline]

Solved, had to call the Initalize hook on the dedicated server, worked fine on the listed server though.