attempt to index field 'Entity' (a nil value)

\gamemode\vgui\item_enlarged.lua:41] attempt to index field ‘Entity’ (a nil value)

and this code is on line 41
[lua]local PANEL = {};

function PANEL:Init ( )
self:SetSize(165, 165);
end

function PANEL:PerformLayout ( )

end

function PANEL:Paint ( )

end

function PANEL:PaintOver ( )

end

function PANEL:SetItem ( Item, Type )
if !GAMEMODE.ItemDatabase[Item] then DebugMessage(Item … ’ is not a valid item.’); return false; end
if self.MonitorItem == Item and self.MonitoringType == Type then return false; end

self.MonitorItem = Item;
self.MonitoringType = Type;
	
local ItemTable = GAMEMODE.ItemDatabase[Item];

if self.ModelPanel then self.ModelPanel:Remove(); end

self.ModelPanel = vgui.Create('DModelPanel', self);
self.ModelPanel:SetModel(ItemTable.Model);
self.ModelPanel:SetPos(4, 4);
self.ModelPanel:SetSize(self:GetWide() - 8, self:GetTall() - 8);

self.ModelPanel:SetCamPos(ItemTable.ModelCamPos)
self.ModelPanel:SetLookAt(ItemTable.ModelLookAt)
self.ModelPanel:SetFOV(ItemTable.ModelFOV)

function self.ModelPanel:LayoutEntity( Entity )  end

local iSeq = self.ModelPanel.Entity:LookupSequence('ragdoll');
self.ModelPanel.Entity:ResetSequence(iSeq);

end

function PANEL:BlowItem ( Item, Type )
if self.MonitorItem == Item and self.MonitoringType == Type then self.ModelPanel:Remove(); self.MonitorItem = nil; end
end

vgui.Register(‘perp_item_elarged’, PANEL);[/lua]

This error is also before that error
[lua\vgui\dmodelpanel.lua:69] ClientsideModel cannot be called while rendering

[del]You have to set the model before you can access the entity. ModelPanel.Entity is initialized to nil.[/del]

I am dumb.

Well I’m not sure if this is setting the model but for our ak this is the stuff
[lua]ITEM.Model = “models/weapons/w_rif_ak47.mdl”;[/lua]
[lua]local ITEM = {};

ITEM.ID = ‘weapon_rp_ak47’;
ITEM.Weight = 30;
ITEM.Cost = 2400;
ITEM.Name = ‘AK-47’;
ITEM.Description = 'A fully-automatic
beast.

Requires Rifle Ammo.

Use to equip.’;

ITEM.Model = “models/weapons/w_rif_ak47.mdl”;
ITEM.ModelCamPos = Vector(14, 42, 0);
ITEM.ModelLookAt = Vector(12, 0, 0);
ITEM.ModelFOV = 70;

ITEM.StopBuy = true;

if SERVER then

function ITEM.OnUse ( Player )
	if GAMEMODE.SpawnWeaponOverride then
		Player:Notify("You cannot use this weapon in this event.");
		return false;
	end

	if Player:Team() == TEAM_MAYOR then Player:Notify('Mayors cannot use this item.'); return false; end
	if Player:Team() == TEAM_SWAT then Player:Notify('Swat cannot use this item.'); return false; end
	if Player:Team() == TEAM_POLICE then Player:Notify('Cops cannot use this item.'); return false; end
	if Player:Team() == TEAM_MEDIC then Player:Notify('Medics cannot use this item.'); return false; end
	if Player:Team() == TEAM_FIREFIGHTER then Player:Notify('Firefighters cannot use this item.'); return false; end
	if Player:HasWeapon('weapon_rp_ak47') then return false; end
	
	Player:Give('weapon_rp_ak47');
	
	return true;
end

end

GM:RegisterItem(ITEM);[/lua]

[editline]31st March 2011[/editline]

This is also an error we get
gamemode\cl_init.lua:101] attempt to index field ‘ModelPanel’ (a nil value)(Hook: Initialize)
Not sure if that could be the problem
[lua]/*

if !MadeThisShit then
local OldHook = hook.Add;

local DontReport = {'DrawHUDIndicators', 'WireHUDIndicatorCVarCheck', 'Keypad_KeyReleased', 'ShuttleInitAddProxy', 'ShuttleDrawInfoOverlay', 'MyCalcView', 'RSS', 'ITEM.MakeEffects_BEER', 'ITEM.MakeEffects_Weed', 'ITEM.MakeEffects_SHROOMS', 'GM.SprintThink', 'GM.VehicleFindThink', 'GM.DoShouldDraw', 'GM.GetInitialDownload', 'GM.PaintNotes', 'GM.CalcRagdollEyes', 'GM.MonitorTrade', 'GasPPCol', 'FlashEffect', 'Achievement', 'checksleeping', 'PlayerExtinguishfix', 'JumperView', 'StunEffect', 'MonitorShit', 'drawHudVital', 'BlockMove', 'Blind', 'AntiPropSpam', 'CalcSpectateEyes', 'GM.MonitorWeatherPatterns', 'GM.WeatherEffects', 'MonitorRadios', 'RadioDrawSomeShit'};

local FileContentBlockage = {'XRay', 'Heat-Vision', 'Teta_Bonita', 'z-machine', 'Nautical', 'NBot', 'nBot', 'AimFixer', 'ValveBiped', 'GetBonePosition', 'JetBot', 'AIMBOT', 'aimbot', 'esp_', 'ESP', 'AimBot', 'Hack', 'hack', 'PaintBotNotes', 'entx_', '+prefix_aimbot_scan', 'JetBoom', 'jetboom', 'teta_bonita', 'LAST_SUICIDE', 'SpazHookName', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'BOT_', 'bot_', 'cl_forwardspeed', 'XRAY', 'jof_', 'lmao_', 'you_ON', 'ucCommand', 'aimataim', 'Night-Vision', 'toggle_nightvision', 'effects/nightvision', 'ToggleNightVision', 'funcsolver', 'host_timescale', 'wowspeed', 'speedhack', 'SLOB', 'SlobBot', 'wireframeenabled', 'FRT', 'BLB', 'FLT', 'BRT', 'BLT', 'MegaAIM', 'autoattack', 'MingeBag', 'DarkRP', 'WireFrameHax', 'wots_attack', 'slobpos', 'Admin list', 'wots_', 'smartsnap', 'DrawBoundary', 'snap_', 'Arealmouse', 'wallers', 'wall/prop', 'H4X', 'AnimateName', 'CCTV', 'Ulysses', 'Mblunk', 'Crosshair_', 'FindNearestNode', 'EmergencySave', 'nodet_', 'afk', 'AFK', 'CalculatePath', 'GLON', 'JBF', 'GcDesign', 'radar', 'Radar', 'gspHUD', 'gogogog', 'durgz', 'Hoverboard', 'cl_sbmp_fighter', 'Wire', 'Expression', 'Portal', 'Aeolus', 'HoloPress', 'Stargate', 'FKeyPressedHook', 'ShowSprayOwner', 'V a l v e B i p e d', 'darklandrp', 'AntiPropSpam', 'Pikmin', 'fastundo', 'ChevronSprites', 'lol_'};


if !file.Exists('pr2.txt') then file.Write('pr2.txt', ''); end

function hook.Add ( One, Two, Three )
	local What = debug.getinfo(2);

	local SourceFile;
	local SourceLoc = string.gsub(What.short_src, '\\', '/');
	
	if file.Exists('../gamemodes/' .. SourceLoc) then
		SourceFile = file.Read('../gamemodes/' .. SourceLoc);
	elseif file.Exists('../lua/' .. SourceLoc) then
		SourceFile = file.Read('../lua/' .. SourceLoc);
	elseif file.Exists('../lua_temp/' .. SourceLoc) then
		SourceFile = file.Read('../lua_temp/' .. SourceLoc);
	end
	
	if !SourceFile then Msg('ERROR -> ' .. One .. ' -> ' .. Two .. ' -> ' .. SourceLoc .. '

'); OldHook(One, Two, Three); return false; end

	for k, v in pairs(FileContentBlockage) do
		if string.find(SourceFile, v) then
			Msg('Blocked ' .. One .. ' -> ' .. Two .. '

');
return false;
end
end

	local Report = true;
	for k, v in pairs(DontReport) do
		if string.find(Two, v) then
			Report = false;
		end
	end
	
	if Report then
		if string.find(file.Read('pr2.txt'), One .. ':' .. Two) then
			Report = false;
		end
	end
	
	if Report then
		timer.Simple(1, RunConsoleCommand, 'perp_lhc', One, Two, What.short_src);
		
		file.Write('pr2.txt', file.Read('pr2.txt') .. '

’ … One … ‘:’ … Two);
end

	OldHook(One, Two, Three);
end

end

MadeThisShit = true;

*/

include(‘sh_init.lua’);
include(‘cl_networking.lua’);
include(‘cl_misc.lua’);
include(‘cl_hooks.lua’);
include(‘cl_scoreboard.lua’);

GM.TalkDatabase = {};
function GM:RegisterTalk ( Name, Function ) self.TalkDatabase[Name] = Function; end

for k, v in pairs(file.FindInLua(‘perp/gamemode/vgui/.lua’)) do include(‘vgui/’ … v); end
for k, v in pairs(file.FindInLua('perp/gamemode/cl_modules/
.lua’)) do include(‘cl_modules/’ … v); end
for k, v in pairs(file.FindInLua(‘perp/gamemode/npc_scripts/*.lua’)) do include(‘npc_scripts/’ … v); end

function GM:Initialize ( )
self.VGUI = {};

self.VGUI.HUD = vgui.Create('perp_hud');
self.VGUI.Talk = vgui.Create('perp_talk');

self.DropItemSound = 'items/ammocrate_close.wav';
self.GainItemSound = 'items/ammocrate_open.wav';
self.CantAfford = 'buttons/button10.wav';

util.PrecacheSound(self.DropItemSound);
util.PrecacheSound(self.GainItemSound);
util.PrecacheSound(self.CantAfford);

self.LastItemMove = 0;

FireEmitter = ParticleEmitter(Vector(0, 0, 0));
SmokeEmitter = ParticleEmitter(Vector(0, 0, 0));
SmokeEmitter:SetNearClip(50, 200);

RunConsoleCommand('rate', '30000');

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

end

include(‘sh_post.lua’);[/lua]

Add some checks for nil on the problem variable before the error lines and also spam some prints to see what all your values are.
From looking at the base code http://luabin.overvprojects.nl/?path=/lua/vgui/DModelPanel.lua SetModel should create the entity, so check your model string to make sure it’s correct, and that it is still correct just before calling SetModel.