Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ServerScriptService.Script:4: invalid argument #2 to 'random' (interval is empty)?

ok so if i try to run this script that will instance a new part at a random vector3 position, it gives me the error in the title.

luis = Instance.new("Part",workspace)
while true do
luis.Size=Vector3.new(5,1,5)
workspace.Part.Position=Vector3.new(math.random(138.5,252.5), (-18.5), math.random(-137.5,-252.5))
	workspace.Part:Destroy()	
	wait(2)
end

3 comments

0

The error occurs when the (minium) 1st value of the parameter - being math.random- is bigger than the second. So, all you'd have to do, is make the 2nd value bigger than the first. That should fix your problem.

0

workspace.Part.Position=Vector3.new(math.random(138.5,252.5), math.random(-19,-18.5), math.random(-137.5,-252.5)) is my new and fixed string but it still gave me the error

0

Try putting (-137.5,-252.5)), (-19,18.5) and (138.5,252.5)

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.