This is probably what you want, as good as it gets as well
local RNGranges = function(...)
local r = math.random(1,#({...}))
return math.random(({...})[r][1],({...})[r][2])
end
print(RNGranges({5,10},{15,20},{5,6},{11,12},{9990,99999}))
Puppynniko's answer will give an error anyways after constant testing.
Basically the code is saying: "Give me a bunch of tables with ranges that you want to math.random() and I will provide a random table with the rng value."
How to use? The comment I wrote states {num,num},{num,num} where in the code, the first random range is 5,10 and then the second is 15,20.
Easy to use.
The best part about this is that you can have infinite ranges, you can put stuff like:
RNGranges({5,20},{60,100},{4,6},{99492349,43293249329})
as well as simple stuff like
RNGranges({10,100})
To prove that this doesn't pick anything outside of the ranges, check this out:
tester code
1 comment
math.random(math.random(10,20),math.random(10,20))?