Tried to use invalid object (type Panel) (Object was NULL or not of the right type

Hello,

for hours now i’ve been having this problem, tried many different ways to fix it myself but with no luck. This is really frustrating me now

When i close my derma panel i get spammed with these errors: then if i open it again as well:



[ERROR] addons/merksstock/lua/autorun/client/cl_merksstock.lua:441: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
  1. SetText - [C]:-1
   2. func - addons/merksstock/lua/autorun/client/cl_merksstock.lua:441
    3. unknown - lua/includes/modules/net.lua:30

[MerK's Stock] Retrieved stock information succesfully.

[ERROR] addons/merksstock/lua/autorun/client/cl_merksstock.lua:441: Tried to use invalid object (type Panel) (Object was NULL or not of the right type)
  1. SetText - [C]:-1
   2. func - addons/merksstock/lua/autorun/client/cl_merksstock.lua:441
    3. unknown - lua/includes/modules/net.lua:30


this is the code involved (line 441 is NextStock:SetText()


	function retrievestock()
		net.Receive( "StockUpdateTimer", function( len, ply )

				NextStock:SetText( a[1] )
				
				PrinterLabel1:SetText( a[2] )
				PrinterLabel2:SetText( a[3] )
				PrinterLabel3:SetText( a[4] )
				PrinterLabel4:SetText( a[5] )
				PrinterLabel5:SetText( a[6] )
				PrinterLabel6:SetText( a[7] )
				
				PrinterHigh1:SetText( a[8] )
				PrinterHigh2:SetText( a[9] )
				PrinterHigh3:SetText( a[10] )
				PrinterHigh4:SetText( a[11] )
				PrinterHigh5:SetText( a[12] )
				PrinterHigh6:SetText( a[13] )
				
				PrinterLow1:SetText( a[14] )
				PrinterLow2:SetText( a[15] )
				PrinterLow3:SetText( a[16] )
				PrinterLow4:SetText( a[17] )
				PrinterLow5:SetText( a[18] )
				PrinterLow6:SetText( a[19] )
				
				PrinterChange1:SetText( a[20] )
				PrinterChange2:SetText( a[21] )
				PrinterChange3:SetText( a[22] )
				PrinterChange4:SetText( a[23] )
				PrinterChange5:SetText( a[24] )
				PrinterChange6:SetText( a[25] )
				
				COMP1Stock = a[26]
				DermaButton1.DoClick = function ()
					GetValueIs = myText1:GetValue()
					TOTALP = math.Round(GetValueIs * COMP1Stock)
					StockName = "PRINTER CORP."
					Shorted = "comp1stocks"
					CurrStock = LocalPlayer():GetPData( Shorted )
					if (CurrStock == nil) then
						LocalPlayer():SetPData(Shorted, "0")
					end
					if tonumber(GetValueIs) ~= nil then
			   			if LocalPlayer():canAfford(TOTALP) == true then
			   				LocalPlayer():ChatPrint("[MerK's Stock] You bought " .. GetValueIs .. " of " .. StockName .. " stock for $" .. TOTALP .. ".", Color( 255,255,255,255 ))
			   				LocalPlayer():SetPData( Shorted, CurrStock+GetValueIs )
			   				LocalPlayer():SetPData(LocalPlayer():GetPData("money") - TOTALP)
			   				LocalPlayer():ChatPrint("[MerK's Stock] You now have " .. CurrStock+GetValueIs  .. " stocks for this company.")
			   			else
			   				LocalPlayer():ChatPrint("[MerK's Stock] You can't afford this.", Color( 255,255,255,255 ))
			   			end
					else	
						LocalPlayer():ChatPrint("[MerK's Stock] You must enter a valid amount.", Color( 255,255,255,255 ))
					end
				end
		end)
	end
	retrievestock()

this is the for loop for what i put in the array:


a = {}
timer.Simple( 1, function() 
	for i=1, 31 do
		if (a* == nil) then
		 a* = "LOAD"
		end
		print(a*)
	end
end )

“LOAD” is supposed to be net.ReadString(), changed it to load for convenience

Thanks in advance

[editline]23rd May 2014[/editline]

Well… right as i post this thread i tried this and it works, so solved D:


a = {}
function GetItAll()
	net.Receive( "StockUpdateTimer", function( len, ply )
		
			for i=1, 31 do
				 a* = net.ReadString()
				if (a* == nil) then
					a* = "Load"
				end
				print(a*)
			end
	end )
end
timer.Simple( 1, GetItAll)