I recently ran into a rather odd problem that seems to have to do with using math.random() using large numbers. When calling math.random() with 2 decently large numbers (roughly 1.9 and 2.1 billion), I get the error “1: invalid argument #2 to ‘random’ (interval is empty)”. I know this is typically caused by calling it with an invalid range, however that isn’t the problem here.

I confirmed this by a simple print statement in the command bar using the two numbers my code supplies which also for some peculiar reason errors as shown below. I’ve seen nothing about math.random failing with larger numbers even far exceeding the billions, however here it is. Has anyone else encountered this and any ideas on a different way of going about it?

Thanks, I’ll use Random instead. I couldn’t find any mention of the upper limit despite my searches for some reason (even on just lua documentations of the math functions) but upon testing a bit more I realized it was the 32 bit integer limit. Glad Random willl work instead.