What would be the best way to make a chance system?

I’m creating a game where the player crafts a weapon and a tier gets applied.
The tier gets randomly selected like 1 in 3 chance of getting tier Basic

What would be the best way of making a system like this?
I’ve messed around with math.random(1, weight) and such but that leads to the issue of the higher numbers getting selected usually.

How would I go about creating a system that is like 1 in 3 chance, 1 in 9 chance, 1 in 27 chance etc…

I appreciate anyone’s input!

I also have viewed a lot of devforum posts that offer an example of a rarity system but not exactly how I’m imagining it so any concepts would help me!

1 Like

Have you tried this?

Edit:

I think you could do the 1 in n chance by setting the item’s chance to 1/n? ex: RareItem = 1/10 (10% chance / 1 in 10 chance)

3 Likes

You could use math.random to make it a random chance from example: 1 in 3 chance