Iifebit
(Lifebit)
August 10, 2020, 5:40am
#1
So basically I created a chance to get a certain item and I have chances for each of them. However I don’t know how to make math.random more likely to choose the item with the higher chance. Any help is appreciated!
There are tons of resources on the internet surrounding this topic, but I think this response on Scripting Helpers sums it up well.
Let's say I had a block, and I wanted that block to be made into a random color. But I would like some colors to be more likely than others (this done accomplished through a table).
Any help is appreciated (Wikis, other Q&A's)
NOTE:The lua...
Here is a thread that has tons of great responses that should help you:
local percentages = {
Common = 50
Uncommon = 25
Rare = 15
Epic = 10
}
local getRandomItem = math.random(1, percentages)
print('Item won: ' .. getRandomItem)
Basically, what I’m trying to do is the print should return the item that was selected at random (Common, Uncommon, Rare, Epic), but I don’t know how to actually get the percentages and have it pick the item based on its percentage of getting picked.
1 Like
Iifebit
(Lifebit)
August 10, 2020, 5:48am
#3
Thanks a lot! That seemed to work.
1 Like