Lua Error

Well im running the PERP gamemode and there is this weird problem, if you scroll over an item you get these 2 errors.


[perp\gamemode\vgui\dmodelpanel.lua:69] ClientsideModel cannot be called while rendering
[perp\gamemode\vgui\item_enlarged.lua:41] attempt to index field 'Entity' (a nil value)


I have no idea what is causing this error but here is the code.

item_enlarged.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);

IF you could help me fix this it would be much appreciated.

Leaked gamemodes arn’t allowed on facepunch.