Ok I guess i’m getting abit sleepy here. Are you sure that the value being passed as index is correct?
Most likely; basically, alongside the error, it does show up search results (for an example, 6 items matching up). But it’s preventing me from executing the rest of the code.
I’ll post the Catalog variable in a bit, maybe it’ll help!
I’ll give this a try as well. (3o chars)
Just to be sure put prints in every for loop like this
for categoryindex,category in pairs(Catalog) do
print(categoryindex, category)
if category ~= "Skintones" then
for subcategoryindex,subcategory in pairs(category) do
print(subcategoryindex, subcategory)
for index,value in pairs(subcategory) do
print(index, value)
local stringword = subcategory[index].Name
if string.find(stringword,SearchKeyword) then
print("Found")
table.insert(CurrentTable,value)
end
end
end
end
end
Catalog variable:
local Catalog = require(ReplicatedStorage["Catalog API"])
(Catalog API) return {
Animations = require(script.Animations),
["Body Parts"] = require(script["Body Parts"]),
Clothing = require(script.Clothing),
Collectibles = require(script.Collectibles),
Featured = require(script.Featured),
UGC = require(script.UGC),
Skintones = require(script.Skintones)
}
(Body Parts) return {
Characters = require(script.Characters),
Faces = require(script.Faces),
Heads = require(script.Heads),
}
(Characters) return {
[1] = {
["Creator"] = "Roblox",
["ID"] = 667,
["Name"] = "Oldschool Animation Pack",
["OutfitID"] = 131929448,
["Price"] = 80,
["Type"] = "UserOutfit"
}
}
Here’s an example of the tree, tried to make it as short as possible.
try using subcategory[value].Name
Line 155:
print(subcategoryindex, subcategory)
Line 152:
print(categoryindex, category)
How are Skintones still messing this up? LMAO
When using that line, it says this:
09:57:52.588 Players.OueIIet.PlayerGui.CatalogAPI_UI.Catalog API:158: attempt to index nil with ‘Name’ - Client - Catalog API:158
In that case replace
if category ~= "Skintones" then
with
if category ~= Catalog.Skintones then
pretty sure this is the issue
It may be surprising, but that actually did the job! Lua is confusing sometimes and it’s ridiculous what the program tends to ask.
Thanks to everyone who helped contribute to this.
The way this is all set up is very confusing to me.
local categories = {"Animations", "Body Parts", "Clothing", "Collectibles",
"Featured", "UGC", "Skintones"}
local Catalog = {}
for _, category in pairs(categories) do
Catalog[category] = require(script[category])
end
return Catalog
Or you could do like:
local Catalog = {}
for _, categoryModule in pairs(script:GetChildren()) do
if categoryModule:IsA("ModuleScript") and Catalog[categoryModule.Name] == nil then
Catalog[categoryModule.Name] = require(categoryModule)
end
end
return Catalog
Just realized this was solved. Still gonna post this just for anyone who might learn from it.
Might check that route out as well! Thanks for posting it.