I’m trying to choose a random rarity from in a table, and then choose a random thing from in said table however idk how to do it but I do have some code that is not working, im sure its simply misunderstanding of syntax
(i just started making the game yesterday so ill make an actual random generator with chances of getting things dont make fun of it)
this is in a module script all the code i am showing
local rarity = math.random(1, 7) --[[ just a placeholder for now as i said for the future randomization
system ]]
print(Fish.Rarities[6]) --[[
i added this line just to test why it wasnt working, it printed attempt to index nil
when i did fish.rarities[rarity] and with this value too
]]
local fish = Fish.Rarities[rarity][math.random(1, #Fish.Rarities[rarity])] --[[
on this line it says attempt to index nil with number
]]
here is the table, all things are in quotation marks. the Rarities index as well as the rarities indexes themselves used to be outside of quotation marks (and therefore also simply 1 equals sign instead of 2) before this, i did some testing while making this post and this is the final code as i have written it
local Fish = {
"Rarities" == {
"Common" == {
"Carp",
"Catfish",
"Cuttlefish",
"Cod",
"Squid",
"Salmon",
"Herring",
"Shrimp",
"Bass"
},
"Uncommon" == {
"Frog",
"Starfish",
"Clownfish",
"Butterfly fish",
"Trout",
"Goldfish",
"Oyster",
"Mackerel"
},
"Rare" == {
"Lionfish",
"Stargazer fish",
"Flying fish",
"Blobfish",
"Seahorse",
"Angler fish",
"Sea urchin"
},
"Epic" == {
"Nurse shark",
"Lemon shark",
"Sunfish"
},
"Legendary" == {
"Sea cow",
"Orca",
"Tiger shark",
"Bull shark",
"Alligator",
"Crocodile"
},
"Mythic" == {
"Anglerfish",
"Whale shark",
"Blue whale",
"Hammerhead shark"
},
"Unique" == {
"Kraken",
"Megalodon",
"Polar bear"
}
},
}