Invalid argument #2 to 'random' (interval is empty)

Greetings,

I am getting this error and I don’t know what is wrong:

The line from the error:
pos1 = math.random(169.234, 98.427)

Please help me fix this error! Thanks.

I think the second value in math.random(1,2) should be higher than the first one
math.random(98.427, 169.234)

1 Like

math.random does not work with decimals, so you may need to generate a larger number and then divide it

3 Likes

Oh, really didn’t notice that, I have multiple numbers generating and I didn’t pay attention to how I organized them. Thank you!

1 Like

Idk it works very well for me tbh

@Doom_Vickstar999: Try the “new” Random thing:

local rnd = Random.new()
print(rnd:NextNumber(98.427, 169.234))

I hate this syntax since you can’t just write it in one line. What in the ever loving heck was the point of making this object oriented? Regardless, you can have much higher precision using this version.

2 Likes

Decablocks meant something like this to get a number from 10.1 and 10.5 to get decimals

local result = math.random(101,105)
result = result / 10
pos1 = math.random(math.round(98.427), math.round(169.234))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.