math.random and Random internally use the same algorithm, so the only difference is that with Random you can create different instances while with math.random you always use the same instance.
Both are fine. But you probably shouldn’t be doing Random.new():NextNumber(0,10) like you suggested in your title. Each successive call of NextInteger (or similar) to a Random object is supposed to generate “good” pseudorandom numbers. There’s no guarantee that a sequence of the first calls to newly created Random objects has the same properties, i.e. you might get “bad” sequences.
Testing the distribution tho it seems fine:
local t = {}
local rolls = 10000000
for i = 1, rolls do
local n = Random.new():NextInteger(1, 10)
t[n] = (t[n] or 0) + 1
end
for k, v in pairs(t) do
print(k, (v/rolls) * 10)
end
The one big advantage of Random is that you can have different RNGs with different states, which is useful if you’re trying to generate the same sequence of numbers from the same seed.
Just a heads-up, you don’t have to call Random.new() multiple times, noting that it is a random number generator. Setting it as a variable is better than getting a new generator every single time, unless you want to refresh the seed. Treat it like an object and use its functions as the equivalent of math.random(), not math.randomseed().