Menu not opening when a button is pressed

Hey hey folks.

I’m having some issues getting a menu to open. I seem to have identified the problem, but I’m not sure why it’s doing what it’s doing.

I’m using gameProcessedEvent so that it doesn’t open when the user is typing, but now it won’t open at all. I have a first person mouse lock that uses the same thing, and it works just fine. What gives?

Here’s my code:

UserInputService = game:GetService("UserInputService")
ReplicatedStorage = game:GetService("ReplicatedStorage")
options = require(ReplicatedStorage.options)

keyPC = Enum.KeyCode.O
keyCons = Enum.KeyCode.ButtonY

UserInputService.InputBegan:Connect(function(key, gameProcessedEvent)
	if gameProcessedEvent then return end -- removing this makes the code work fine, provided it opens when typing
	if key.KeyCode == keyPC or key.KeyCode == keyCons then
		options.ShowOptions() -- opens the options/settings menu
	end
end)
1 Like

Have you checked on your module? Or is there any errors showing up in your output?

My assumption is that the key “I” and “O” is a shortcut to zoom in and zoom out of a camera. That’s probably why gameProcessedEvent flags it.

2 Likes

I use the same module in other scripts to open the options menu, and those work fine. I’ll try changing the keybind to something else real quick to test your theory

1 Like

I changed it to X temporarily and it works just as intended! Thank you :slight_smile:

1 Like

Good to know it’s working. Also, consider using InputTypes. Since it might also make your job easier with adding mobile support later on.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.