#How do I copy a table containing array from one function to another?

11 messages · Page 1 of 1 (latest)

hoary steppe
#

Hi I have these two functions that I wish to copy the results of one function to another, in order to merge the results, which in this case are both arrays.

pickedIndex.labelSearchFolder = function(para_targetfolder:Folder)
    local targetfolder = {}
    for i,val_TextLabel in para_targetfolder:GetDescendants() do
        if val_TextLabel:IsA("TextLabel") then
            table.insert(targetfolder, val_TextLabel)
            table.clone(targetfolder)
            print("This is what's inside 'targetFolder':", targetfolder)
            return targetfolder
        end
    end
    if #targetfolder ~= 0 then
        print("Connection established between target folder and labelSearchFolder. Here are it's contents:", targetfolder)
    end

end```

```bash
pickedIndex.indexedTableFrame = function () --Field Name is indexedTableFrame
    --I need to mesh the results from pickFrameIndex and..
    local FrameIndexChildren = pickFrameIndex
    for i,v in FrameIndexChildren do
        if v:GetFullName() == game.Players.LocalPlayer.PlayerGui.ScreenGui.OutlineFrame:GetFullName() then
            print("disgusting frameoutline found")
            table.remove(FrameIndexChildren, 2)
            continue
        end
    end
    local randChild = math.random(1,#FrameIndexChildren) --Probably needs modification later, only returns BattleOptionsFrame (09/24/2024)
    print("Frame number",randChild, "was picked from the list of frames.")
    
    return FrameIndexChildren[randChild]
    end```
#

In this case I want to copy the children of targetfolder to FrameIndexChildren.

sonic shadow
#

So you want to merge two arrays into a third array?

#

@hoary steppe

hoary steppe
rotund chasmBOT
#

studio** You are now Level 3! **studio

hoary steppe
# sonic shadow Return the arrays

How would I access them as parameters inside a new function? Should I run this function inside the function that holds the array I want to extract?

pickedIndex.grabTableIWant = function(para_Table1, para_Table2)
    local testGrabSomething = {}
    local getTable1 = pickedIndex.labelSearchFolder()
    print("Bleh! Test print!", getTable1)
    
end```
#

This isn't the full function of course, but this is what I imagine I should be doing.

weak kiln
sonic shadow