Error with Addons! Help me


hook.Add( "PostPlayerDraw", "HatVendor_DrawHats", function(ply)
	if !ply:Alive() then return end
	if ply == LocalPlayer() and (GetViewEntity():GetClass() == 'player' and (GetConVar('thirdperson') and GetConVar('thirdperson'):GetInt() == 0)) then return end
	
	for k, v in pairs( ents.FindByClass("hat_base") ) do
		if v:GetParent() == ply then
			if !IsValid(ply.Hat) then
				ply.Hat = ClientsideModel( v:GetModel(), RENDERGROUP_BOTH )
			end
			
			local hat = ply.Hat
			if !hat then return end
			
			local attachment = ply:GetAttachment(ply:LookupAttachment( "eyes" ))
			if !attachment then return end
			
			local pos = attachment.Pos
			local ang = attachment.Ang
			
			if hat:GetModel() != v:GetModel() then
				hat:SetModel(v:GetModel())
			end
			
			for k, v in pairs( HatsModuleConfig.Hats ) do
				if v.model == hat:GetModel() then
					configHat = v
				end
			end
			
			if !configHat then return end
			
			local offpos = configHat.offPos
			pos = pos + hat:GetAngles():Forward()*offpos.x + hat:GetAngles():Right()*offpos.y + hat:GetAngles():Up()*offpos.z
			
			local offang = configHat.offAng
			ang:RotateAroundAxis( ang:Forward(), offang.p )
			ang:RotateAroundAxis( ang:Right(), offang.y )
			ang:RotateAroundAxis( ang:Up(), offang.r )
			
			hat:SetModelScale(configHat.scale,0)
			
			hat:SetPos(pos)
			hat:SetAngles(ang)
			
			hat:SetRenderOrigin(pos)
			hat:SetRenderAngles(ang)
			hat:SetupBones()
			hat:DrawModel()
			hat:SetRenderOrigin()
			hat:SetRenderAngles()
			
			hat.LastUpdated = CurTime()
		end
	end
end)

hook.Add( "Think", "HatVendor_RemoveHat", function()
	if IsValid(LocalPlayer().Hat) and ( (GetViewEntity():GetClass() == 'player' and (GetConVar('thirdperson') and GetConVar('thirdperson'):GetInt() == 0)) or LocalPlayer().Hat.LastUpdated < CurTime() ) then
		LocalPlayer().Hat:Remove()
	end
end)

///////////////////////////////////////////////////////////////////////////////////////////////
Error in console :

  1. fn - gamemodes/darkrp/gamemode/modules/hats/cl_hats.lua:60
    2. unknown - addons/ulib/lua/ulib/shared/hook.lua:110

[ERROR] gamemodes/darkrp/gamemode/modules/hats/cl_hats.lua:60: attempt to compare nil with number

  1. fn - gamemodes/darkrp/gamemode/modules/hats/cl_hats.lua:60
  2. unknown - addons/ulib/lua/ulib/shared/hook.lua:110

///////////////////////////////////////////////////////////////////////////////////////////////

***How to do to not reveal errors!


Post the whole cl_hats file and all errors you get.

Thanks man