You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Im working on a shop system for my game, and I’m testing out making the items refresh randomly using tables. -
What is the issue? Include screenshots / videos if possible!
I have a table, which also contains two tables, one for each item category. For some reason, both of the category tables are nil, and I don’t get what’s wrong. I’ve never encountered this error before. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried making sure everything was loaded before trying to use the table, which didn’t change anything. The big table is not nil while the two smaller ones are.
result of printing items table, then paws and titles tables
The script is a LocalScript inside of a folder in StarterPlayerScripts.
local items = {
Paws = {
"paws_wooden",
"paws_thorns",
"paws_flower",
"paws_water",
"paws_gilded",
"paws_cherryblossom",
"paws_lava",
"paws_blackhole",
},
Titles = {
"title_OwO",
"title_UwU",
"title_baller",
"title_silly_face_1",
"title_silly_face_2",
"title_happy",
"title_nya",
"title_pawballer",
"title_silly",
"title_sunshine_rainbows",
"title_always_sleepy",
"title_fluffy",
"title_goober",
"title_meow",
"title_nya_with_sillyface",
"title_silliest",
"title_not_a_buff",
"title_ultimate_silly",
"title_best_paws",
"title_LOL",
}
}
local function SelectNewItems()
local Selected = {}
for i = 1, 4, 1 do
local item_category = items[math.random(1, 2)]
local item = math.random(1, #item_category)
table.insert(Selected, items[item_category][item])
end
return Selected
end
SelectNewItems()
Image of Output after running the script