Luck System With Luck Boost

I have been researching for hours and I can’t seem to make “math.random()” or “Random.new()” to not go to 0 easy. I am trying to find a way to do a luck system without it getting at least < 5 easy without any luck.

Here is how I set up my pet table:

local Pets = {
            Pet1= {
             Luck = 50;
            };

            Pet2= {
             Luck = 30.5
            };

            Pet3= {
             Luck = 14.75;
            };

            Pet4 = {
             Luck = 4.25;
            };

            Pet5= {
             Luck = 0.45;
            };

            Pet6= {
              Luck = 0.05; 
            };
}

Don’t know if this would help at all, but it seems like you’re going for a pet simulator type of game.

Try looking up some uncopylocked simulator games and take a check into their egg code, that’s how many coders get help with their coding. How ever this may not be for everyone, so a Youtube tutorial could help.

As I mentioned I have researched for hours on youtube and devforum and tried many other ways but in all of the ways I’ve tried I keep getting to 0 - 1 really easy in just a couple times looping

Sorry I do not understand what you’re trying to achieve, can you try to explain ìt in another way?

When I do math.random(100) or using the random.new I always get close to 0 every couple of times printing in the command line (which will be same in game) I want to find a way to make it harder to get close to 0 without gamepasses (basically free to play) and easier with luck (pay to win)

If you want to include decimals in your math.random, do the following.

local Roll = math.random(1,1000)/10 -- This will get .0 decimals.
local Roll = math.random(1,10000)/100 -- This will get .00 decimals.
local Roll = math.random(1,100000)/1000 -- This will get .000 decimals.

I also tried those as I seen in a devforum post but the same happened still getting closer to 0 easy.

If you want to include a luck gamepass, then you could do something like this.

local Roll = math.random(1,10000)/100 -- This will get .00 decimals.
-- Roll is in this case 30.16
if DoubleLuckGamepass then
	Roll/2
end
-- Roll is now 15.8
1 Like

Funny thing… I’ve also tried that. To see what I mean print this in command line a couple times and it will print numbers under 10

print(math.random(100))

It printed 3 in just a couple prints for me and this is what I want to avoid that’s too easy and can destroy game balance.

Well, you should not avoid this. There is only 1/100 chance that it prints 3 exactly, and 3/100 chance that it prints 3 or anything below. If you manipulate the outcome of the math.random, to do so higher numbers is more likely, then it’s not a %-chance any longer. Instead you should set your rarities to something lower, if you wish that they become more rare.

If you use this sample

local Roll = math.random(1,10000)/100 -- This will get .00 decimals.

Then the chance of hitting 0.03 is 1/10000, and that number or anything below is 3/10000.

local LuckBoost = 1.5;
local Pets = {
Pet1= {
Luck = 50;
};

        Pet2= {
         Luck = 30.5
        };

        Pet3= {
         Luck = 14.75;
        };

        Pet4 = {
         Luck = 4.25;
        };

        Pet5= {
         Luck = 0.45;
        };

        Pet6= {
          Luck = 0.05; 
        };

}
local LuckBoost = 1.5;
local PetLuck = Pets[“Pet1”].Luck;
local LuckBase = PetLuck;
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);
local Luck = LuckBase * LuckBoost;
math.random(Luck);
print(Luck);

You should use math.random( Luck )