Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RarityTable = {
- Common = 45;
- Rare = 35;
- Epic = 18;
- Legendary = 2; -- these rarities are changeable. Change the numbers how ever you want them!
- }
- local weight = 0
- for _, Chance in pairs(RarityTable) do
- weight += (Chance)
- end.
- local ranNum = math.random(1, weight)
- weight = 0
- for Rarity, Chance in pairs(RarityTable) do
- weight += (Chance)
- if weight >= ranNum then
- print("Rarity "..Rarity.." has been discovered!")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment