I've been using keyboard input as the main input in my game. However, I cannot define the same key with any other methods on different scripts. Here's a example;

Script one:

function onKeyPress(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.K then
		script.Parent.Visible = false
		script.Parent.Parent.memory.Visible = true
	end
end
 
game:GetService("UserInputService").InputBegan:connect(onKeyPress)

Script two:

function back(actionName, userInputState, inputObject)
	if userInputState == Enum.UserInputState.Begin then
		if selection == "one" then
			print("Success")
		end
		if selection == "two" then
			script.Parent.Visible = false
			script.Parent.Parent.Frame.Visible = true
		end
	end
end

game.ContextActionService:BindActionToInputTypes("backmenu", back, false, Enum.KeyCode.K)

Can anyone help me? I've tried them both using ContextActionService or both using UserInputService..