Increasing Luck in My Weight System

hello everyone i have a probleme for my weight system i don’t understand for increas luck to my system

--all pets
local PetsModule = require(script.Parent)

return {
	Dog ="Dog", 1.2, "Commun", 50),
	Cat ="Cat", 1.5, "Rare", 30),
	Mouse ="Mouse", 2, "Epic", 15),
	Bat ="Bat", 3, "Legendary", 4.9),
	Bird ="Bird", 5, "Mythical", 0.1)

local pets = require(script.Parent.Pets)

local function getRandomWeight()
	local x, weight = 0, 0
	for _, v in pairs(pets) do
		x = x + v.Weight
	local random =, x)
	for _, v in pairs(pets) do
		weight = v.Weight  --Before this post, I was looking for solutions
		if weight >= random then
			return v
			random -= weight

return {
	Callback = getRandomWeight

If you are increasing luck by integers (whole numbers), one way of ‘increasing luck’ is to simply roll the pet n times, where n is the luck multiplier, then taking the best result out of the rolls.

I’ll look into ways to have luck with non-integer values, and will get back to you

1 Like

You can apply the luck multiplier directly to each item’s weight each roll. I’d suggest creating a temporary table to put these modified values in when doing this.

for index, pet in ipairs(pets) do
	pet.Weight *= math.pow(luckMultiplier, index - 1)