local itemTable = {
["C_BasicWand"] = {Name = "Basic Wand", Rarity = "Common", Physical = nil, Spell = nil, Value = 1, Req = 1, Upgrades = nil, CurrentUpgrades = 0},
["UC_BasicWand"] = {Name = "Basic Wand", Rarity = "Uncommon", Physical = nil, Spell = nil, Value = 1, Req = 1, Upgrades = nil, CurrentUpgrades = 0},
["R_BasicWand"] = {Name = "Basic Wand", Rarity = "Rare", Physical = nil, Spell = nil, Value = 1, Req = 1, Upgrades = nil, CurrentUpgrades = 0},
["E_BasicWand"] = {Name = "Basic Wand", Rarity = "Epic", Physical = nil, Spell = nil, Value = 1, Req = 1, Upgrades = nil, CurrentUpgrades = 0},
["L_BasicWand"] = {Name = "Basic Wand", Rarity = "Legendary", Physical = nil, Spell = nil, Value = 1, Req = 1, Upgrades = nil, CurrentUpgrades = 0},
}
local lootTable = {
{Name = itemTable.C_BasicWand, Chance = 55},
{Name = itemTable.UC_BasicWand, Chance = 40},
{Name = itemTable.R_BasicWand, Chance = 25},
{Name = itemTable.E_BasicWand, Chance = 15},
{Name = itemTable.L_BasicWand, Chance = 1},
}
local function returnSumOfWeight(lootTable)
local sum = 0
for _, item in ipairs(lootTable) do
sum = sum + item.Chance
end
return sum
end
local function getRandomItem(lootTable)
local randomNumber = math.random(returnSumOfWeight(lootTable))
for _, item in ipairs(lootTable) do
if randomNumber <= item.Chance then
return item.Name
else
randomNumber = randomNumber - item.Chance
end
end
end
function Items.PickItem()
local item = getRandomItem(lootTable)
return item
end
return Items
so i have a random item picker here and in the itemTable i want each item to have a random physical, spell, and amount of upgrades but if i just do math.random for the values then for that playtest all of the values will be that picked random value and i do not want that, i want it random every single time for each and every one how could i do that?