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

1 comment

0

what happens when you print gui? what happens when you print gui.GUI? what happens when you print gui.GUI.Items?