The way you can do it is by having a modifier used during your rarity check
function checkPull(boostModifier: number)
--setting the PRNG seed based on the server time to guarantee a more random assortment
math.randomseed(workspace:GetServerTimeNow())
--boostModifier is a scalar value, so we multiply the outcome
local rng = math.clamp(1 - (math.random() * boostModifier), 0, 1)
for i,v in Rarities do
if rng < v then return tostring(i) end
end
return nil
end
The reason you want to do something like this instead of adding the modifier to the result is so that you aren’t cutting off a section of the RNG table
For example: Say your player buys a 30% luck boost, if you were to add the modifier in your player would only be able to roll a minimum of 30/100, meaning that they’re guaranteed 80% of the time to get an uncommon or better which depending on your luck table may be a problem
Now let’s use that 30% luck boost but with a multiplication system. Well a 30% increase in luck would mean multiplying your rng roll by x1.3,
Here’s an example of how this can impact your rng roll using a 30% RNG boost
--No Modifier: 0.40009932572819973 - AKA getting a common drop
--With Modifier: 0.22012912344665958 - AKA getting an uncommon drop
Hey, this doesnt rly work. it returns nil kinda often if i try with like 5x luck boost or something.
i appreciate your answer.
i think it is not working properly because of the math.random() * boostmodifier. because if its like 3 0.5 then 1- 1.5 = -0.5
The reason it returns nil is because when the rng rolls a 0 there is no option with a 0% chance of success, to solve this simply have the default value for no other matches be the highest tier return.
Also the boost modifier math is correct, because it’s always clamped between 0 and 1