Hello! I have this rarity system which works. However, it only returns one value so for example, if I get common, It’ll keep returning common. Please help!
Local Script
local rs = game:GetService("ReplicatedStorage")
local folder = rs:WaitForChild("Shapes", 5)
local Spawner = workspace:WaitForChild("Spawner")
local Chance = require(rs:WaitForChild("Chance"))
local gui = script.Parent
local Button = gui.TextButton
local Rarity = {Chance.PickRarity("Rarities")}
Button.MouseButton1Down:Connect(function()
print(Rarity)
end)
Module Script
local Chance = {}
local Rarities = {
Common = 0, -- 60% chance
Rare = 0.6, -- 30% chance
Legendary = .9, -- 10% chance
--Mythic = 0.99, -- 1% chance
}
function Chance.PickRarity()
local Index = math.random()
local HighestRarity = "Common"
for RarityName, Value in pairs(Rarities) do
if Index >= Value and Value >= Rarities[HighestRarity] then
HighestRarity = RarityName
end
end
return HighestRarity
end
return Chance