function DropSystem.DropItems()
local Sum = 0
for itemName, Chance in pairs(ItemTable.Weapons) do
Sum += Chance --ERROR IS HERE
end
local RandomNumber = math.random(Sum)
for itemName,Chance in pairs(ItemTable.Weapons) do
if RandomNumber <= Chance then
return itemName
else
RandomNumber -= Chance
end
end
end
local ItemsModule = {}
local ItemModels = game:GetService("ReplicatedStorage").Items.Models
ItemsModule.Weapons = {
["Sword"] = {Chance = 55, PhysicalPower = math.random(25,60), SpellPower = math.random(1,10), Value = 100, Upgrades = 200, Model = ItemModels.Sword},
["Wand"] = {Chance = 30, PhysicalPower = math.random(1,15), SpellPower = math.random(6,40), Value = 100, Upgrades = 200, Model = ItemModels.Wand},
["Staff"] = {Chance = 15, PhysicalPower = math.random(1,20), SpellPower = math.random(30,80), Value = 100, Upgrades = 200, Model = ItemModels.Staff},
}
return ItemsModule
so im trying to make a loot table so the player can be awarded items with a chance to get rarer ones and stuff, i think i understand what im doing wrong here, i just dont know how to fix it.