Basically, I have my items below in a module
local classItems = {}
classItems.Weapons = {
Knight = {
['Sword'] = {Cost = 0, Currency = '', Rarity = 'Common'},
['Claymore'] = {Cost = 100, Currency = 'Gold', Rarity = 'Common'},
['Highlander'] = {Cost = 200, Currency = 'Gold', Rarity = 'Common'},
['Light'] = {Cost = 250, Currency = 'Gold', Rarity = 'Rare'},
['Long Sword'] = {Cost = 500, Currency = 'Gold', Rarity = 'Rare'},
['Trusty'] = {Cost = 50, Currency = 'Gems', Rarity = 'Epic'},
['Riptide'] = {Cost = 100, Currency = 'Gems', Rarity = 'Epic'},
['Shai'] = {Cost = 200, Currency = 'Gems', Rarity = 'Legendary'},
['Judgement'] = {Cost = 250, Currency = 'Gems', Rarity = 'Legendary'},
},
Archer = {
['Bow'] = {Cost = 0, Currency = '', Rarity = 'Common'},
['Stringer'] = {Cost = 50, Currency = 'Gold', Rarity = 'Common'},
['Steel'] = {Cost = 100, Currency = 'Gold', Rarity = 'Common'},
['Imperial'] = {Cost = 150, Currency = 'Gold', Rarity = 'Common'},
['Hawkeye'] = {Cost = 250, Currency = 'Gold', Rarity = 'Rare'},
['Darkage'] = {Cost = 500, Currency = 'Gold', Rarity = 'Rare'},
['Splinter'] = {Cost = 25, Currency = 'Gems', Rarity = 'Epic'},
['Daedric'] = {Cost = 50, Currency = 'Gems', Rarity = 'Epic'},
['Ornate'] = {Cost = 100, Currency = 'Gems', Rarity = 'Legendary'},
},
}
classItems.Armours = {
Knight = {
['Griswold'] = {Cost = 0, Currency = '', Rarity = 'Common'},
['Redcliff'] = {Cost = 100, Currency = 'Gold', Rarity = 'Common'},
['Jahrfyre'] = {Cost = 150, Currency = 'Gold', Rarity = 'Rare'},
['Enchanted'] = {Cost = 75, Currency = 'Gems', Rarity = 'Rare'},
['Empyrean'] = {Cost = 150, Currency = 'Gems', Rarity = 'Epic'},
},
Archer = {
['Iron'] = {Cost = 0, Currency = '', Rarity = 'Common'},
['Ace'] = {Cost = 100, Currency = 'Gold', Rarity = 'Common'},
['Daring'] = {Cost = 150, Currency = 'Gold', Rarity = 'Rare'},
['Adventurous'] = {Cost = 75, Currency = 'Gems', Rarity = 'Rare'},
['Alivia'] = {Cost = 150, Currency = 'Gems', Rarity = 'Epic'},
},
}
return classItems
Now I want to get each of those individual items and chuck them in a table
local AllItems = {}
-- Get the random item
for i, v in pairs(ClassItems) do
print(i, v) -- Would Print Weapons table: 0000013BDD252330 / Armours table: 0000013BDD2542C0
end
Doing table.insert(AllItems, v) would just insert the Knight and it’s table, instead of just all the items inside the Knight table. Please note, I cannot change how the item table is sorted/arranged as it is this way for other reasons when referencing it from other scripts.
What I am trying to accomplish eventually is for one of the items be selected. It will be based on percentages too, which I plan on doing as so:
Say
Common = 50%
Rare = 25%
Epic = 15%
Legendary = 10%
Then I’d insert all the common items into the table 50 times, all the rare items into the table 25 times, so on for the rest. This way it’s not just a completely random pull and the item it would select would be based off this percentage