local velocityPlatform = game.Workspace.VelocityPlatform
function vel(z)
velocityPlatform.Velocity = Vector3.new(0,0,z)
wait(2)
end
while true do
vel(math.random(-5,-200))
end
✓ ANSWER ACCEPTED
now why can't I do this? "bad argument #2 (interval is empty)"
2 answers
✓ Accepted answer
math.random() expects integers to be given in ascending order, so the smaller integer must come before the larger one. In your case this doesn’t happen (-5 > -200), hence the error is seen. The interval b-a for math.random(a, b) can’t be negative. Just rearrange the numbers:
local velocityPlatform = game.Workspace.VelocityPlatform
function vel(z)
velocityPlatform.Velocity = Vector3.new(0,0,z)
wait(2)
end
while true do
vel(math.random(-200, -5))
-- You could also do vel(-math.random(5, 200))
end
local velocityPlatform = game.Workspace.VelocityPlatform
function vel(z)
velocityPlatform.Velocity = Vector3.new(0,0,z)
wait(2)
end
while true do
vel(math.random(-200,-5))
end
You have to put the smaller number then the bigger number. It's a simple change, but can be unnoticeable. I'd prefer this instead :
-math.random(5,200)
This discussion is preserved as it was. New answers, comments, and votes are closed.
