local Store = {Trails = {Bubbles = {Name = "Bubbles", Cost = 1000}}, Outfits = {Name = "BusinessMan", Cost = 250}}
local Trails = (Store["Trails"])
print(#Trails)
it Outputs 0
its says theres nothing in the list Trails. I Dont know if im missing something super obvious but ive been trying to work it out for a while. i dont use dictionarys much lol
local Store = {Trails = {Bubbles = {Name = "Bubbles", Cost = 1000}}, Outfits = {Name = "BusinessMan", Cost = 250}}
local Trails = (Store["Trails"])
local function len(t)
local n = 0
for _ in pairs(t) do
n = n + 1
end
return n
end
for i = 1,len(Trails) do
print("In for loop")
print(Trails[i])
end
im trying to make a code that cycles through the trails locating the other dictionarys. but Trails[i] returns nil
The index i (any numbers actually) aren’t defined in your dictionary. To iterate over a dictionary you have to use pairs, similarly to how the solution post did it.