So I'm trying to make a script that moves a part 10 times in a randomly selected x and z position.
part = script.Parent local x = math.random(100, -100) local z = math.random(100, -100) for i = 1, 10 do wait(1) part.Position = Vector3.new(x, 15, z) end
However when I run it it gives me this error:
Workspace.Part.Script:2: bad argument #2 to 'random' (interval is empty)
I don't know what this means.
The reason this is happening is because you gave the arguments for the math.random incorrectly. math.random() gives us a random number between blah and blah, less to more. What you did was give it more to less which doesn't really work, instead of
math.random(100,-100)
do
math.random(-100,100)
Here is your script fixed
part = script.Parent local x = math.random(-100, 100) local z = math.random(-100, 100) for i = 1, 10 do wait(1) part.Position = Vector3.new(x, 15, z) end
looks like your math.randoms aren't quite right! when using math.random(), the minimum value must be provided first, followed by the maximum value. simply switching the numbers on your snippet should solve the problem.
part = script.Parent local x = math.random(-100,100) local z = math.random(-100,100) for i = 1, 10 do wait(1) part.Position = Vector3.new(x, 15, z) end