[TTT] Adding a karma check to VOICE.Tick

I am an inexperienced LUA coder looking for help with my modifications to get TTT’s voice drain to adjust depending on player’s karma. I don’t believe I’m using BOOLs or hooks properly at all, but here what I have:

Setting up a NWBool on players based on karma, hooked to GM:PlayerSpawn


hook.Add("GM:PlayerSpawn", "BatteryKarmaCheck", function(ply)
  for _, ply in pairs(player.GetAll()) do
      if ply:GetBaseKarma() => 1700 then
       ply:SetNWBool("karmabattery", true)
  else
      ply:SetNWBool("karmabattery", false) 
  end)


In cl_voice.lua



function VOICE.Tick()
   if not GetGlobalBool("ttt_voice_drain", false) then return end

   local client = LocalPlayer()
   if client:GetNWBool("karmabattery") = true and VOICE.IsSpeaking() and (not IsTraitorChatting(client)) then
      client.voice_battery = client.voice_battery - (GetDrainRate() * 0.5)

   if client:GetNWBool("karmabattery") = false and VOICE.IsSpeaking() and (not IsTraitorChatting(client)) then
      client.voice_battery = client.voice_battery - GetDrainRate()

      if not VOICE.CanSpeak() then
         client.voice_battery = 0
         RunConsoleCommand("-voicerecord")
      end
   elseif client.voice_battery < battery_max then
      client.voice_battery = client.voice_battery + GetRechargeRate()
   end
end

It currently just screams this at me


[ERROR] 
  1. unknown - [C]:-1

Error in hook Tick: gamemodes/terrortown/gamemode/cl_voice.lua:648: attempt to compare nil with number
stack traceback:
	gamemodes/terrortown/gamemode/cl_voice.lua:648: in function 'Tick'
	gamemodes/terrortown/gamemode/cl_init.lua:326: in function <gamemodes/terrortown/gamemode/cl_init.lua:318>
	[C]: in function '•‎​‬‪•'



I’d really appreciate FP’s guidance!