Trying to make a random position generator

So, basically, I have two blocks, marker A and marker B.
I created a variable for each’s blocks Z positions, and I tried then to run the following code (as the variables being pos1 and pos2)

local myFinalNumber = math.random(pos1, pos2)

The output was the following:
local myFinalNumber = math.random(pos1, pos2):1: bad argument #2 to 'random' (interval is empty)

Does anyone has a way to fix this or has a better method?


will error that if the second argument(y) is less than the first(x)

just make it so that the smaller number is the first argument and the larger number is the second

I was not sure if this could affect the function, i’ll check and update you.

That fixes my problem! Thanks you!

1 Like