Hello. I am trying to make a pause menu for Xbox using the selection button.
The issue is that when I press the selection button on an Xbox remote, the menu does not open on the first button press but rather on the second button press.
Edit: For me, the player character can walk around when in pause menu, but cannot walk around when they get out of the menu. The player controls are being disabled automatically, but I don’t know how I could disable that from happening.
I have been trying to solve this issue off and on for the last month or so and I can’t seem to find a solution. I have used 3 different Xbox One Controllers, and all 3 had the same result.
local userInputService = game:GetService("UserInputService")
local pauseMenuHasBeenOpened = false
userInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.ButtonSelect then
if pauseMenuHasBeenOpened == false then
pauseMenuHasBeenOpened = true
script.Parent.Enabled = true
else
pauseMenuHasBeenOpened = false
script.Parent.Enabled = false
end
end
end)
Can’t reproduce. Used a PS4 controller (emulating Xbox controls/passing the same inputs) as well as my keyboard by adding a different input type. Neither case took me two tries.
Check if you have something else bound to Select or if it’s a case of your own controller. Additionally on a side note you can shorten this script to just reverse the Enabled property. Doesn’t seem like you need the other flag anyhow.
userInputService.InputEnded:Connect(function (input)
if input.KeyCode == Enum.KeyCode.ButtonSelect then
script.Parent.Enabled = not script.Parent.Enabled
end
end)
I didn’t actually try to move around but if you’re using a gamepad then GuiService sinks movement input because the thumbsticks are used to navigate selectable Gui elements. I’m not particularly sure how that’s relevant to the problem you outlined in the OP though.
Should have clarified, but when exiting the menu with an Xbox remote my character gets stuck and I can’t move. But when in the pause menu, I can move around.
The selection button disables the players controls so they can use UI, but is there a way to turn that off?
Set SelectedObject to nil. Since it’s not handled, GuiService continues to hold focus on the selected button even when the Gui gets hidden. Up to you to remove that selection.