Math.random Generates Same Integers

I helped a friend with a game using the specific function math.random. It always generates 2 random numbers instead of the total maximum amount there is. I have no specific line of code for today, but I will just give an example.

local random = math.random(1, #tools:GetChildren())
print(#tools:GetChildren(), random)
Output: (7,2)
Output: (7,4) x3
Output: (7,2)..

#Tools:GetChildren() is the maximum amount of how the number should generate.

There’s probably a different script calling math.randomseed() and ruining the global seed. You should use Random.new() instead.

3 Likes