Weird warning that even no one created topic about this

I wanna solve this weird warning

**When i plug my gamepad, studio gives warning (else everything works fine)
image
**

Also theres gamepad connected event in module

function InputActivated(Value, Type)
	if not (Value == nil) then
		Type.Value = Value
	else
		Type.Value = false
	end
end

function GamepadEnabled(Function)
	local FunctionValue = false
	local Type = "Gamepad"
	
	if UserInputService.GamepadEnabled then
		FunctionValue = true
	else
		FunctionValue = false
	end
	
	Function(FunctionValue, Type)
	InputActivated(FunctionValue, GamepadEnabledValue)
	
	UserInputService.GamepadConnected:Connect(function()
		Function(true, Type)
		InputActivated(true, GamepadEnabledValue)
	end)
	
	UserInputService.GamepadDisconnected:Connect(function()
		Function(false, Type)
		InputActivated(false, GamepadEnabledValue)
	end)
end

When i plug my controller game dedects it and sets the selectionobject

function SetSelectedObject(Value)
	if Value == true then
		GuiService.SelectedObject = Buttons.NewGame
	else
		GuiService.SelectedObject = nil
	end
end

LocalInput.gamepadEnabled(SetSelectedObject)

Alright so let’s see, you could try writing this function for your selection object.

function SetSelectionGroup()
    -- Check if the group already exists before adding it
    if not GuiService:GetSelectionGroup(selectionGroupName) then
        GuiService:AddSelectionParent(selectionGroupName, yourSelectionObject)
    end
end

Also be sure that these two are in your script:

local GuiService = game:GetService("GuiService")
local selectionGroupName = "RBXBackpackSelection"

This will avoid an overwriting of an already existing selection group, which should fix your problem.

image

i get this error in this line

   if not GuiService:GetSelectionGroup(selectionGroupName) then

Understood, so Ima quickly try to restructure your code, I think this was a rookie mistake on my end, I don’t think that GuiService is even used in the current API, let me try again.

local GuiService = game:GetService("GuiService")
local selectionGroups = {} -- Table to track existing selection groups

function addSelectionGroup(selectionGroupName, elements)
    print("Attempting to add selection group: " .. selectionGroupName)

    -- Check if the selection group already exists
    if not selectionGroups[selectionGroupName] then
        print("Selection group '" .. selectionGroupName .. "' does not exist. Creating new group.")
        GuiService:AddSelectionParent(selectionGroupName, elements)
        selectionGroups[selectionGroupName] = true -- Mark this group as created
        print("Selection group '" .. selectionGroupName .. "' successfully created.")
    else
        warn("Selection group '" .. selectionGroupName .. "' already exists. Overwriting.")
        GuiService:AddSelectionParent(selectionGroupName, elements)
        print("Selection group '" .. selectionGroupName .. "' overwritten with new elements.")
    end
end

-- Example usage (replace 'YourGroupName' and 'YourElements' with actual values)
local testGroupName = "TestGroup"
local testElements = script.Parent -- Replace with the actual UI container
addSelectionGroup(testGroupName, testElements)

I added a ton of print statement, so tell me what is in the output.