Setting selected object not working

i can 100% confirm the button does exist and can be selected with a gamepad
output reads “Setting GuiService.SelectedObject to invalid GuiObject”

-- gamepad selection
if inputService.GamepadEnabled then
     guiService.SelectedObject = script.Parent.options.inner[tostring(1)].button
end

is this in a local script? that may be the problem.

1 Like

that isn’t the problem, sorry but thank q for yo help

could you give a little more context? it would help a-lot for solving your problem.

1 Like

Screen Shot 2022-03-24 at 10.52.55 PM
this is the button and choice would be renamed to “1”

So you’re trying to rename the choice frame?

1 Like

selected object is the current selected gui object for xbox controllers

no, i’m trying to make the xbox gamepad’s selected gui object the button

First, try printing a string right after the if statement, for it may be your condition. I also usually have problems with UserInputService.

1 Like

k, yep it printed correctly 30char

1 Like

And also, could you give me a bigger tree of where this object is? and also where the script is located. This will be especially helpful for me and others who see this topic.

1 Like

I see you’re trying to reference choice frame with tostring(1) assuming it’s going to be named 1 at the same time this script runs?

That may be your error.

2 Likes


i want the button to be selected when that line of code runs, the button also btw is the “see ya” text this is for npc chat system

yes it correctly gets renamed to “1”

One thing, why are you trying to index inner with tostring(1) when you can just say "1", or try renaming the object altogether because Roblox Studio probably doesn’t like things named as 1 digit numbers…

Also, I’m not an expert in XBOX GUIs but your problem may be lying in the fact that you’re trying to select a button, which may sound a little counter-intuitive, but that may be why. The error states that you set SelectedObject to an valid GuiObject, so that could be why.

1 Like

roblox doesn’t let you just type numbers like that in a path
the reason i’m trying to select it is because it makes a much smoother and more user friendly experience for xbox players

Yes, I understand that, but try just setting up your scripts different to name the choice frame something like ONE instead.

1 Like

nope didnt fix anything 30char

man… I’m stuck.

There’s one line of code in the if statement, it should be simple. Maybe someone with more expertise in GUIs can help you. I’m so sorry :frowning_face:

One thing I can say though, is, for the highest chance of getting your post solved, give ALL of the details about your problem. Don’t just give everyone a script, and say “it not working”. Tell us what type of script it is normal, module, etc…, where it is, what the error is, what other scripts are running that could have the slightest possibility of affecting the current script, and what you’ve already tried.

That will easily speed up the process of your post getting solved.

1 Like

thank you so much for your help and ya i should’ve gave more details. i think it’s a glitch but i will keep trying to fix it

1 Like