Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with getting objects and storing them?

Asked by 4 years ago

Hello all. I am wondering how to get the first 10 objects in a folder, based on their names. The objects names are Item1, Item2, Item3, and so on. This is my code so far, but when I try to index the item with item.Name it gives me an error of

Attempt to index local "item" (a nil value).

Why is the value nil? Please help.

local function loadPage(gui) 
    local Items = gui.GUI.Items
    local first10 = {}
    for i = 1, 10, 1 do
        print("Item".. tostring(i))
        local item = Items:FindFirstChild("Item".. tostring(i))
        table.insert(first10, item.Name)
    end
end

If more info is needed please leave a comment

0
what happens when you print gui? what happens when you print gui.GUI? what happens when you print gui.GUI.Items? royaltoe 5144 — 4y

Answer this question