Here's what I have made right now:
local Items = { ["Blue"] = 500; -- common ["Orange"] = 200; -- uncommon ["Red"] = 50; -- rare ["Purple"] = 1; -- legendary }; local Spawns = {}; local function setSpawns() for i = 1,500 do for item,rarity in pairs(Items) do if (Items[item] > 0) then table.insert(Spawns,item); Items[item] = Items[item] - 1; end; end; end; end; setSpawns(); local function spawnItem() local Item = Spawns[math.random(1,#Spawns)]; print(Item); end; while (wait(1)) do spawnItem(); end;
I'm not sure that this is the most accurate/efficient way for a rarity system though. Any help or information would be much appreciated.