RunService.RenderStepped:Connect(function()
local LatestInputType = UserInputService:GetLastInputType()
if LatestInputType == Enum.UserInputType.Gamepad1 then
-- controller
GuiService.SelectedObject = Gold.Mid['1']
GuiService:AddSelectionTuple('Gold', {Gold.Mid, Gems.Mid})
else
-- pc
end
end)
No matter what I press, the box stays on the first option
EDIT I know why now (it’s in a RenderStepped event) but if this is the case, how else can I constantly check to see if the user is using their gamepad or their pc?
Why not just hold the selected result in a variable?
local SelectedObject = Gold.Mid['1']
RunService.RenderStepped:Connect(function ()
local LatestInputType = UserInputService:GetLastInputType()
SelectedObject = GuiService.SelectedObject
if LatestInputType == Enum.UserInputType.Gamepad1 then
-- controller
GuiService.SelectedObject = SelectedObject
GuiService:AddSelectionTuple('Gold', {GoldMid, Gems.Mid})
else
-- pc
end
end)
This is probably not the smartest way to accomplish this functionality overall, but I haven’t looked into a better method yet. For now, for the purposes of answering this question, I think this should be appropriate enough.