Lua Error - Urgent help needed


    local Models = {};
for k, v in pairs(file.Find('../models/players/humans/group01/clo1*.mdl')) do table.insert(Models, v); end

	// Male Model	
	local Position = 1;
	local ModelPanel = vgui.Create('DModelPanel', DermaPanel);
	ModelPanel:SetModel('models/players/humans/group01/' .. Models[1]);  <= LINE 7
	PrintTable(Models);
	ModelPanel:SetPos(ScrW() * .5 - W * .5, ScrH() * .5 - H * .5);
	ModelPanel:SetSize(W, H);
	
	ModelPanel:SetFOV(70)
	ModelPanel:SetCamPos(Vector(14, 0, 60))
	ModelPanel:SetLookAt(Vector(-1, 0, 64))
	
	function ModelPanel:LayoutEntity( Entity )  end
	
	local iSeq = ModelPanel.Entity:LookupSequence('ragdoll');
	ModelPanel.Entity:ResetSequence(iSeq);
	
	local W2, H2 = 64, 64;
	
	local ForwardButton = vgui.Create('DButton', DermaPanel);
	ForwardButton:SetSize(W2, H2);
	ForwardButton:SetPos(ScrW() * .5 + W * .6, ScrH() * .5 - H2 * .5);
	ForwardButton:SetText(">");
	
	local BackButton = vgui.Create('DButton', DermaPanel);
	BackButton:SetSize(W2, H2);
	BackButton:SetPos(ScrW() * .5 - W * .6 - W2, ScrH() * .5 - H2 * .5);
	BackButton:SetText("<");
	BackButton:SetEnabled(false);
	
	function BackButton.DoClick ( )
		if Position != 1 then
			Position = Position - 1
			ModelPanel:SetModel('models/players/humans/group01/' .. Models[Position]);
			
			if string.find(Models[Position], 'fe') then
				ModelPanel:SetCamPos(Vector(14, 0, 60))
				ModelPanel:SetLookAt(Vector(-1, 0, 64))
				ModelPanel:SetFOV(70)
			else
				ModelPanel:SetCamPos(Vector(14, 0, 62))
				ModelPanel:SetLookAt(Vector(-1, 0, 66))
				ModelPanel:SetFOV(70)
			end
			
			if Position == 1 then
				BackButton:SetEnabled(false);
			else
				ForwardButton:SetEnabled(true);
			end
		end
	end
	
	function ForwardButton.DoClick ( )
		if Position != #Models then
			Position = Position + 1
			ModelPanel:SetModel('models/players/humans/group01/' .. Models[Position]); <= LINE 86
			
			if string.find(Models[Position], 'fe') then
				ModelPanel:SetCamPos(Vector(14, 0, 60))
				ModelPanel:SetLookAt(Vector(-1, 0, 64))
				ModelPanel:SetFOV(70)
			else
				ModelPanel:SetCamPos(Vector(14, 0, 62))
				ModelPanel:SetLookAt(Vector(-1, 0, 66))
				ModelPanel:SetFOV(70)
			end
			
			if Position == #Models then
				ForwardButton:SetEnabled(false);
			else
				BackButton:SetEnabled(true);
			end
		end
	end
	
	local W3, H3 = 128, 32;
	
	local ConfirmButton = vgui.Create('DButton', DermaPanel);
	ConfirmButton:SetSize(W3, H3);
	ConfirmButton:SetPos(ScrW() * .5 - W3 * .5, ScrH() * .5 + H * .6);
	ConfirmButton:SetText("Confirm Selection");
	
	function ConfirmButton.DoClick ( )
		RunConsoleCommand('nextramit', Models[Position]);
		DermaPanel:Remove();
	end
	
	DermaPanel:MakePopup()
end


and


     self.VGUI.Talk:SetVisible(false);    self.VGUI.Talk:SetAlpha(0);
    self.VGUI.Talk.ModelPanel:Remove(); <= LINE 103
    gui.EnableScreenClicker(false); 

It says Line #7 attempt to index global ‘Models’ (a nil value) and Line # 103 attempt to index field ‘ModelPanel’ (a nil value)(Hook: Initialize) How do I get these to stop screwing up? I would appreciate the help.

Under ModelPanel:SetModel(‘models/players/humans/group01/’ … Models[1]);

Put “PrintTable(Models);”

Please do show the output.

Where is “Models” defined?

self.VGUI.Talk.ModelPanel:Remove(); <= LINE 103
You sure it’s ModelPanel?
Try: self.VGUI.Talk:Remove();self.VGUI.Talk = nil;

I still need some help for the code on top top relating to: ModelPanel:SetModel(‘models/players/humans/group01/’ … Models[1]);

[lua]for k, v in pairs(file.Find(’…/models/players/humans/group01/clo1*.mdl’)) do table.insert(Models, v); end[/lua]

Change to:

[lua]for k, v in pairs( file.Find(“models/players/humans/group01/clo1*.mdl”, true) ) do
table.insert(Models, v);
end;
[/lua]

Tried to use invalid object (type Panel) (Object was NULL of not of the right type) @ Line 86 Please help!