Hello! This is an issue that’s pretty much stumping me. I’m trying to get something to randomize a Vector3, but this part in the function for it is stumping me. The table NewValues prints OK, but the random function won’t accept it. It’s made from 2 vector3s.
local newValues = {
x1 = max.X,
x2 = min.X,
y1 = max.Y,
y2 = min.Y,
z1 = max.Z,
z2 = min.Z
}
print(newValues)
local newRandoms = {
x = math.random(newValues.x1,newValues.x2), -- erroring line
y = math.random(newValues.y1,newValues.y2),
z = math.random(newValues.z1,newValues.z2)
}
I believe the problem is that you’ve got the arguments in the wrong order. For math.random() to work, the smaller value has to come before the larger when defining the arguments. Switching the values around should work:
The interval is empty error only occurs when the second value is larger than the first.
What are the values of min.X and max.X? Assuming they vary, maybe print their values before making the random calculation to make sure that x2 is less than x1.