TTT PreventAttack Error

Hello,

I was gone for a week and got back today. And realised that a Gmod update broke my 2 TTT Servers.

No one can switch weapons, until we activate fast weapon switch.

But without it, we get the following error:


gamemodes/terrortown/gamemode/cl_keys.lua:33: attempt to call method 'PreventAttack' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/cl_keys.lua:33

Hope someone can help me!

This is my cl_keys.lua


function GM:PlayerBindPress(ply, bind, pressed)
   if not IsValid(ply) then return end

   if bind == "invnext" and pressed then
      if ply:IsSpec() then
         TIPS.Next()
      else
         WSWITCH:SelectNext()
      end
      return true
   elseif bind == "invprev" and pressed then
      if ply:IsSpec() then
         TIPS.Prev()
      else
         WSWITCH:SelectPrev()
      end
      return true
   elseif bind == "+attack" then
      if WSWITCH:PreventAttack() then             --Line 33--
         if not pressed then
            WSWITCH:ConfirmSelection()
         end
         return true
      end
   elseif bind == "+sprint" then
      -- set voice type here just in case shift is no longer down when the
      -- PlayerStartVoice hook runs, which might be the case when switching to
      -- steam overlay
      ply.traitor_gvoice = false
      RunConsoleCommand("tvog", "0")
      return true
   elseif bind == "+use" and pressed then
      if ply:IsSpec() then
         RunConsoleCommand("ttt_spec_use")
         return true
      elseif TBHUD:PlayerIsFocused() then
         return TBHUD:UseFocused()
      end
   elseif string.sub(bind, 1, 4) == "slot" and pressed then
      local idx = tonumber(string.sub(bind, 5, -1)) or 1

      -- if radiomenu is open, override weapon select
      if RADIO.Show then
         RADIO:SendCommand(idx)
      else
         WSWITCH:SelectSlot(idx)
      end
      return true
   elseif string.find(bind, "zoom") and pressed then
      -- open or close radio
      RADIO:ShowRadioCommands(not RADIO.Show)
      return true
   elseif bind == "+voicerecord" then
      if not VOICE.CanSpeak() then
         return true
      end
   elseif bind == "gm_showteam" and pressed and ply:IsSpec() then
      local m = VOICE.CycleMuteState()
      RunConsoleCommand("ttt_mute_team", m)
      return true
   elseif bind == "+duck" and pressed and ply:IsSpec() then
      if not IsValid(ply:GetObserverTarget()) then
         if GAMEMODE.ForcedMouse then
            gui.EnableScreenClicker(false)
            GAMEMODE.ForcedMouse = false
         else
            gui.EnableScreenClicker(true)
            GAMEMODE.ForcedMouse = true
         end
      end
   elseif bind == "noclip" and pressed then
      if not GetConVar("sv_cheats"):GetBool() then
         RunConsoleCommand("ttt_equipswitch")
         return true
      end
   elseif (bind == "gmod_undo" or bind == "undo") and pressed then
      RunConsoleCommand("ttt_dropammo")
      return true
   end
end

The file including the function is here: https://github.com/garrynewman/garrysmod/commit/f73e0f4efdebe80143ada5fc16e49a27fa91dcc6

An addon must be overriding it if you’re getting that error.

Mhmm.
Something of Exho I belive.
This has been posted here like 2 times in the past 3 days. Please do a quick google search before making a new thread. Thankyou.

I can only assume you are referring to my Octagonal HUD which has just now been fixed and updated on both my Github and Workshop