Need some lua help.

I’m working on an old gamemode (a little project of mine), and I’m still not a pro at lua and I’m have an error that says:



[ERROR] gamemodes/zombiesurvival/gamemode/ccgm/init.lua:1089: bad argument #1 to 'pairs' (table expected, got nil)
  1. pairs - [C]:-1
   2. UpgradeCheckThink - gamemodes/zombiesurvival/gamemode/ccgm/init.lua:1089
    3. v - gamemodes/zombiesurvival/gamemode/ccgm/init.lua:1117
     4. unknown - lua/includes/modules/hook.lua:82


Looking at the code that is giving the error, I cannot seem to see what the problem is… Can anyone help me?


function UpgradeCheckThink()
	for _,user in pairs(player.GetAll()) do
		local teamups
		if user:Team()==TEAM_HUMAN then teamups="Human" elseif user:Team()==TEAM_UNDEAD then teamups="Zombie" end
		
		for k,v in pairs(UPGRADES[teamups]) do
			--PrintTable(v)
			local upname=v.Name
			local upmax=v.ValMax
			
			local userval = user:GetUpgrade(k)
			--MsgN("init.lua 1094 ====")
			--MsgN(upmax)
			--MsgN(userval)
			
			if userval>upmax then
				user:PrintMessage(3,"[CCGM] You have more than the maximum points on your '"..k.."' upgrade. Refunding points.")
				user:SetUpgrade(k,upmax)
				user:AddUpgradePoints(userval - upmax)
			end
		end
	end
end

local function CCGM_Think()
	TurretThink()
	LastHumanRewardThink()
	EndRoundFixThink()
	SpectateFixThink()
	AdrenalineThink()
	HeadcrabCrushThink()
	AdvertsThink()
	NameCheckThink()
	UpgradeCheckThink()
end
hook.Add("Think","CCGM Think",CCGM_Think)