I have a round-based game I was working on and sometimes you can get special rounds. I pick them out using this:
Chance = {1, 2, 3, 4, 5} Choice = (Chance[math.random(#Chance)]) if Choice == 1 then -- do something elseif Choice == 2 then -- do something else -- and so on
Although lets say "Choice" happens to be 2. If it picks 2, it seems like it picks 2 more often for a few turns. If it were to pick one, it'd pick one more often for a few turns. I was wondering if there was a better way to do this or if I just happened to be getting the same number a few times in a row.
Use "math.randomseed", this randomizes the number table of math.random.
math.randomseed(tick()) Chance = {1, 2, 3, 4, 5} Choice = (Chance[math.random(#Chance)]) if Choice == 1 then -- do something elseif Choice == 2 then -- do something else -- and so on
Read more on random number generation here: https://developer.roblox.com/en-us/articles/Random-Number-Generation