10th rarity is worse than the 2nd rarity

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making a rarity game and all the rarities are stored like number
    so it goes
    1 - Common
    2 - Uncommon
    3 - Rare
    4 - Epic
    5 - Legendary
    and more

  2. What is the issue? Include screenshots / videos if possible!
    basically when i get the 10th rarity it doesnt count.
    If i have Common rarity the 10th rarity counts but once i get uncommon it overrides the rarity
    image (the print says the new best rarity)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried changing the values of the table to like 20 or 30 but it breaks the game
    and i tried looking for solutions but couldnt find any

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

this is the code which makes it choose the best rarity

if RolledNumber >= BestRarityNumber.Value then
		BestRarityNumber.Value = RolledNumber
		BestRarity.Value = RolledRarity
end
1 Like

Could you post the full code? It’s hard to help when you only post a tiny snippet.

oh yeah sure this is it

Blockquote
local Rarities = game.ReplicatedStorage.Main.Rarities
local Rarity = require(game.ReplicatedStorage.Main.Modules.RaritySystem)
local RaritiesTable = require(game.ReplicatedStorage.Main.Modules.RarityList)
local BestRarity = game.ReplicatedStorage.Main.Values.BestRarity
local BestRarityNumber = game.ReplicatedStorage.Main.Values.BestRarityNumber
local bignum = require(game.ReplicatedStorage.BigNum)
local AllRarities = {}
local ls = script.Parent.Parent.Parent.Parent.Parent.leaderstats
local Rerolls = ls.Rerolls.Value
script.Parent.Reroll.MouseButton1Click:Connect(function()
local Auto = script.Parent.Auto.Value
local WaitTime = game.ReplicatedStorage.Main.Values.RarityWaitTime.Value
if Auto == false then
AllRarities = RaritiesTable.Rarities
local RolledRarity = Rarity.GetItem(RaritiesTable.Rarities)
local RolledNumber = game.ReplicatedStorage.Main.Values.RarityNumber.Value
local RolledChance = RaritiesTable.Rarities[tonumber(RolledNumber)][2]
local converted = bignum.convert(RolledChance)
print(RolledRarity)
script.Parent.Rarity.Text = RolledRarity… " (1/“…bignum.short(converted)…”)" … " (“…RolledNumber…”)“… " (”…BestRarityNumber.Value…“)”
game.ReplicatedStorage.Main.Values.RarityChosen.Value = RolledRarity
game.ReplicatedStorage.Main.Values.RarityChance.Value = RolledChance
script.Parent.Rarity.Color:Destroy()
local NewColor = Rarities:FindFirstChild(tostring(RolledRarity)).Color:Clone()
NewColor.Parent = script.Parent.Rarity
Rerolls += 1
if RolledNumber >= BestRarityNumber.Value then
BestRarityNumber.Value = RolledNumber
BestRarity.Value = RolledRarity
end
else
print(“Cannot reroll while auto rerolling!”)
end
end)

please put three backticks (```) the one under your escape button

It seems that the issue might be related to the condition in the last few lines.

Updated code:

if RolledNumber > BestRarityNumber.Value then
    BestRarityNumber.Value = RolledNumber
    BestRarity.Value = RolledRarity
end

This should ensure that the best rarity is always updated, even if a lower rarity is rolled after a higher one.