Numpad help

I am making an entity that emulates a numpad key depending on what round the game is when the key is pressed.
For some reason, I get the error message [lua\includes\modules
umpad.lua:105] attempt to index field ‘keystate’ (a nil value)

The numpad key is supposed to remain active for “roundspawntime”, then deactivate.

There’s also an interval I set to be between each round

I copied and editedthe numpad.activate and deactivate code from gmod wiki, so I might have copied it wrong or something i changed might not have worked.

Here’s part of the code

[lua]
local roundspawntime = 5
local interval = 5
local active = 1

function ENT:SpawnFunction( ply, tr )

round = 0
if ( !tr.Hit ) then return end

local SpawnPos = tr.HitPos + tr.HitNormal * 36

local ent = ents.Create( "RoundCounter" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent

end
function ENT:Use()

--Checks if counter is active
if active == 1 then

	--Sets counter to inactive
	active = 0
	
	--Increases the round number
	round = round + 1
	
	--Activates numpad key of round number
	numpad.Activate(self:GetOwner(), _, { tostring(round) }, self:GetPlayerIndex())
	
	--Creates a timer that will turn off the spawners after the round spawn time ends.
	timer.Create( "spawntimer", roundspawntime, 1, function()
		numpad.Deactivate(self:GetOwner(), _, { tostring(round) }, self:GetPlayerIndex())
	end )
	
	--Reactivates the round counter after the interval has passed
	timer.Create( "intervaltimer", interval, 1, function()
		active = 1
	end )
	
end

end
[/lua]