So I’ve been working on the scripting for my UI and I’m currently making it more gamepad friendly however the issue I am currently running into is when I click my menu I have it disabling the navigation and removes the selection however it is not doing that and believes the button is still pressed and it stays in that state until you hover over it again.
I’m just curious if I’m doing this correctly or if this is a Roblox bug.
Code that manages the menu opening/closing
ReplicatedStorage.Inputs.Interface.Menu.Pressed:Connect(function()
Haptics.UIClick:Play()
if MainGui.Menu:HasTag("Open") then
ControllerService:Deselect()
MainGui.Menu:RemoveTag("Open")
return
end
MainGui.Menu:AddTag("Open")
task.wait(0.1)
ControllerService:Select(MainGui.Menu.Body.Options.Coins, true)
end)
Controller service its requiring too
local Controller = {}
const GuiService = game:GetService("GuiService")
const UserInputService = game:GetService("UserInputService")
function Controller:Select(Gui: GuiBase, UseGamepad: boolean)
if UseGamepad and UserInputService.PreferredInput ~= Enum.PreferredInput.Gamepad then
return
end
GuiService.GuiNavigationEnabled = true
GuiService.SelectedObject = Gui
end
function Controller:Deselect()
GuiService.SelectedObject = nil
GuiService.GuiNavigationEnabled = false
end
return Controller