Attempt to index nil with number

So, I’m making a game and u have to hold a building for 100 seconds to win, the cap is 100, I’m trying to make a chat command that changes the cap to another number, when I try to do it it gives me this error:

image

I tried to use tonumber(args[1]) but it still doesnt work and gives me the same error

Script Im using:

_G.termCap = 100

local prefix = ":"
local admins = {your_user_id_here}

local function checkIfAdmin(plr)
	local isAdmin = false
	for i,v in pairs(admins) do
		if plr.UserId == v then
			isAdmin = true
		end
	end
	
	return isAdmin
end


commands.cap = function(plr, args)
	--local newCap = tonumber(args[1])
	
	_G.termCap = args[1]
	wait()
	game.ReplicatedStorage.gameStuff.termCap.Value = _G.termCap
end

game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(message, recipient)
			if checkIfAdmin(plr) == true then
				local split = message:split(" ")
				local fullcmd = split[1]
				local cmd = fullcmd:split(prefix)
				local cmdName = cmd[2]
				cmdName = string.lower(cmd[2])

				if commands[cmdName] then

					local args = {}

					for i = 2, #split, 1 do
						table.insert(args,split[i])
					end

					commands[cmdName]()

				end
			end		
		end)
end)

Nothing is being passed through the function

_G is very slow and outdated. Use module scripts instead!