Not Sure How to Title This Problem

Okay, I am working on a radio and creating a small menu for admins so they can add and remove songs easily. I have run into a slight problem with this. I am not getting any lua errors but when I start the game and run the command to open the menu, nothing comes up. While in the same game i can re-save the file and the next time i run the command it works perfectly find. Any help would be greatly appreciated and here is the code. It is kinda messy because i have tried many things and none of them have worked. After i get this working i will clean it up a little bit.

The CreateNotification is a custom notification system i made and it works fine.

Also, the file is in my lua/autorun folder




if CLIENT then

	AddCSLuaFile( "lulzradio_admin.lua" ) //This is the name of this file.

end

if SERVER then

	function SaveSongs( tab )
		local json = util.TableToJSON( tab )
		file.Write( "radiosongs.txt", json )
	end 

end

if CLIENT then

	local width = ScrW() * 0.5
	local height = 575
	local xpos = ( ( ScrW() * 0.5 ) - ( width * 0.5 ) )
	local ypos = 100
	local musictable = util.JSONToTable( file.Read( "radiosongs.txt", "DATA" ) )
	
	local title = ""
	local artist = ""
	local genre = ""
	local url = ""


	function DrawShit()
		
		local function AddSongMenu(  )
			local MainFrame = vgui.Create( "DFrame" )
			MainFrame:SetSize( 300, 170 )
			MainFrame:SetPos( xpos, ypos )
			MainFrame:SetTitle( "Add Song" )
			MainFrame:MakePopup()
			
			local Title = vgui.Create( "DTextEntry", MainFrame )
			Title:SetWide( MainFrame:GetWide() - 10 )
			Title:SetPos( 5, 35 )
			Title:SetEnterAllowed( true )
			Title:SetValue( "Title" )
			
			local Artist = vgui.Create( "DTextEntry", MainFrame )
			Artist:SetWide( MainFrame:GetWide() - 10 )
			Artist:SetPos( 5, 60 )
			Artist:SetEnterAllowed( true )
			Artist:SetValue( "Artist" )
			
			local Genre = vgui.Create( "DTextEntry", MainFrame )
			Genre:SetWide( MainFrame:GetWide() - 10 )
			Genre:SetPos( 5, 85 )
			Genre:SetEnterAllowed( true )
			Genre:SetValue( "Genre" )
			
			local URL = vgui.Create( "DTextEntry", MainFrame )
			URL:SetWide( MainFrame:GetWide() - 10 )
			URL:SetPos( 5, 110 )
			URL:SetEnterAllowed( true )
			URL:SetValue( "URL" )
			
			local FinBut = vgui.Create( "DButton", MainFrame )
			FinBut:SetWide( MainFrame:GetWide() - 10 )
			FinBut:SetTall( 20 )
			FinBut:SetPos( 5, 135 )
			FinBut:SetText( "Add Song" )
			FinBut.DoClick = function()
				title = Title:GetValue()
				artist = Artist:GetValue()
				genre = Genre:GetValue()
				url = URL:GetValue()
				
				if title != "" and title != "Title" and artist != "" and artist != "Artist" and genre != "" and genre != "Genre" and url != "" and url != "URL" then
				
				table.insert( musictable, { artist, title, genre, url } )
				
				SaveSongs( musictable )
				
				MainFrame:Close()
				
				else
				
					LocalPlayer():CreateNotification( "Please fill out the form correctly!", 6 )
				
				end
			end
		end


			local DatMainFrame = vgui.Create( "DFrame" ) 
			DatMainFrame:SetSize( width, height )
			DatMainFrame:SetPos( xpos, ypos )
			DatMainFrame:SetTitle("")
			DatMainFrame:MakePopup()
			DatMainFrame:SetVisible( true )
			DatMainFrame:ShowCloseButton(true)
			
			local AddSong = vgui.Create( "DButton", DatMainFrame )
			AddSong:SetSize( DatMainFrame:GetWide() - 10, 25 )
			AddSong:SetPos( 5, DatMainFrame:GetTall() - 30)
			AddSong:SetText( "Add Song" )
			AddSong.DoClick = function()
				DatMainFrame:Close()
				AddSongMenu()
			end
			
			local AppList = vgui.Create( "DListView", DatMainFrame )
			AppList:SetSize( DatMainFrame:GetWide() - 10, DatMainFrame:GetTall() - 65 )
			AppList:SetPos( 5, 30 )
			AppList:SetMultiSelect( false )
			AppList:AddColumn( "Title" )
			AppList:AddColumn( "Artist" )
			AppList:AddColumn( "Genre" )
			AppList.OnRowRightClick = function( panel, line )
				local MenuButtonOptions = DermaMenu()
				MenuButtonOptions:AddOption("Remove", function()
					table.remove( musictable, AppList:GetLine(line):GetID() )
					SaveSongs( musictable )
					AppList:RemoveLine( AppList:GetLine(line):GetID() )
				end)
				MenuButtonOptions:Open()
			end

			for k, v in pairs( musictable ) do
				AppList:AddLine( musictable[k][2], musictable[k][1], musictable[k][3] )
			end
	end

	function IfAdminDraw()
		if LocalPlayer():IsAdmin() then
			DrawShit()
		else
			LocalPlayer():CreateNotification( "You are not an admin!", 5 )
		end
	end

	concommand.Add("lulzradio_admin_open", IfAdminDraw)

end


AddCSLuaFile is a serverside file for sending a lua script to the client. You should work on debugging by maybe placing print()'s in places you’re testing.

Yea, AddCSLuaFile was one of those things i just threw in there to see if it fixed it an it didnt

AddCSLuaFile must be in the if SERVER then part of the code. Also you can leave the file part blank to include the current file:
[lua] if SERVER then AddCSLuaFile() end[/lua]

Still nothing. When i enter the command it doesn’t say that there is no command named that, it is just that nothing happens.

create the command on SERVER then use net.Start for call the vgui, i did that for my derma menu

You can create clientside concommands just fine.

I never got work one…

Console commands work fine for me when i create them clientside in other files. Just not working correctly in this one. It is not the console command.