TTT Help with an error

[ERROR] gamemodes/terrortown/gamemode/cl_hudpickup.lua:81: attempt to call method ‘Alive’ (a nil value)

  1. unknown - gamemodes/terrortown/gamemode/cl_hudpickup.lua:81

I keep seeing this error pop up in the logs and I’m not sure what’s causing it.

Do you have any custom hud?

Yeah, I do. Payday 2 HUD from Coderhire/SF, I run V1.

Mind posting the function its contained in?

Download the latest version from ScriptFodder. Newest version is Version 1.0.3

On the most recent but the owner of it won’t work on V1 anymore, only V2.

[editline]30th August 2015[/editline]

function GM:HUDAmmoPickedUp( itemname, amount )
   if (not LocalPlayer():Alive()) then return end

   local itemname_trans = LANG.TryTranslation(string.lower("ammo_" .. itemname))

   if self.PickupHistory then

      local localized_name = string.upper(itemname_trans)
      for k, v in pairs( self.PickupHistory ) do
         if == localized_name then

            v.amount = tostring( tonumber(v.amount) + amount )
            v.time = CurTime() - v.fadein

   local pickup = {}
   pickup.time      = CurTime()      = string.upper(itemname_trans)
   pickup.holdtime  = 5
   pickup.font      = "DefaultBold"
   pickup.fadein    = 0.04
   pickup.fadeout   = 0.3
   pickup.color     = Color(205, 155, 0, 255)
   pickup.amount    = tostring(amount)

   surface.SetFont( pickup.font )
   local w, h = surface.GetTextSize( )
   pickup.height = h
   pickup.width  = w

   local w, h = surface.GetTextSize( pickup.amount )
   pickup.xwidth = w
   pickup.width = pickup.width + w + 16

   if (self.PickupHistoryLast >= pickup.time) then
      pickup.time = self.PickupHistoryLast + 0.05

   table.insert( self.PickupHistory, pickup )
   self.PickupHistoryLast = pickup.time


Check the LocalPlayer validity I guess? That’s the only reason the error would occur, although, I don’t know why the function would be run before the LocalPlayer is valid.