What I am doing: I currently am trying to reverse engineer a Light-Saber tool in order to work smoother with FIltering Enabled. Currently the error I get is on a script that is a child to the tool. (here is a picture of the error https://prnt.sc/h7hc3m)

---------------------------------------------------------------------------------------------
-- When Tool is select
function onEquippedLocal()
	bin.Blade.Transparency = 0
	bin.Blade2.Transparency = 0
	
	function onKeyPress(inputObject, gameProcessedEvent)
		if inputObject.KeyCode == Enum.KeyCode.Q and script.Parent.Parent.Name ~= "Backpack" then
			OnKeyToggle()
		end
	end
	
end

-- When Tool is unselect
function onUnequippedLocal()
	if ISI.Value == true then
		unequipanimation()
	end
end
---------------------------------------------------------------------------------------------
-- Tells it when to run certain functions
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

^This is the relevant block of code from the script where the error happened^

The error I get is: "Attempt to connect failed: Passed value is not a function" Which I do not really understand why it would say that. Is it because The KeyPress function is in another function or something?

Any help or your own experiences would help me greatly, thank you.