GetChildByName||doc136761

September 20, 2022

Format

Window:GetChildByName(name)

Describe

Recursively find child windows. Returns the child window with the given name. If there is no child window with this name, this function returns nil.

parameter

Variable name Type Describe
name string Instance name of the window to get

Return value

Type Describe
Window Window instances found

    Code example

    Get the window under the subset based on the window instance name

    --Create two image controls with instance names image1 and image2
    local saveWindow1 = UI:CreateGUIWidget(Enum.WidgetType.Image, "image1")
    local saveWindow2 = UI:CreateGUIWidget(Enum.WidgetType.Image, "image2")
    
    --Set the two picture controls to the UI root node
    saveWindow1.Parent = UI.Root
    saveWindow2.Parent = UI.Root
    
    --Get the window instance of the subset based on the window instance name
    local getWindow1 = UI.Root:GetChildByName("image1")
    local getWindow2 = UI.Root:GetChildByName("image2")
    
    -- get the correct window instance
    print(saveWindow1 == getWindow1)
    print(saveWindow2 == getWindow2)