STOOL help please

ok I have some questions about a RD2 stool mod i am developing in beta for RD4 later,

I want to add the (DModelPanel) to the stool but for some reason when i add the code it dosen’t appear on the tool or with edits the whole tool menu disappears and i get clientside lua error.
You can get an idea if you have LS2 and how the tool is coded with the tables in it.
Using the DModelPanel to show the LS device and set its skin in a menu then spawning it.

So my questions are:

  1. Could those tables be causing the problem?
  2. Can i move those tables to the entities cl_init.lua or something file and they still work?
  3. I want this to be serverwide (if possible) meaning if a player does not have the mod it is passed with lua cache.

function TOOL.BuildCPanel( window )

		window:SetName( "Tiberium Storage Preview" )
		window:SetSpacing( 10 )
	local window = vgui.Create( "DModelPanel" )

		window:SetSize( 100,200 )		
		window:SetCamPos( Vector(  246 ,  235 ,  143 ) )
		window:SetLookAt( Vector( -246 , -235 , -143 ) )

	local icon = vgui.Create( "DModelPanel", window )
	window:AddItem( window )

Thats the model view window code i have so far. Im not sure its totally correct either as far as linking menu button to show the model on the window, but this line is where i get an error: