Arrays not looping through items

I cannot loop through an array inside an array? or maybe its just roblox heres my code.

if datastore:GetAsync("Items") then
	local items = datastore:GetAsync("Items")
	local item = items["Items"]
	for i, #item do
		print("item looped")
	end
    print("Success on Giving Items")
end

It wont print “item looped” it just full on ignores the code and prints success still.
the only thing it can print is the array with all the data like print(item) or print(items) and shows me that it does have things to loop through but it still doesn’t. If you have answers please help.

show me what “item” contains
123123

it contains the data of a player and it shows all the items the player owned when i print the array it shows the items

What loop is this? that’s not how you structure a loop

If table have custom indexes, #TABLE is return 0

Working script:

if datastore:GetAsync("Items") then
	local items = datastore:GetAsync("Items")
	local item = items["Items"]
	for i,v in pairs(item) do
		print("item looped")
	end
    print("Success on Giving Items")
end

that does work! maybe “for i do” loops probs just don’t work for the table inside a table I guess but thank you so much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.