math.random() outputs duplicate results from time to time. Take a look at this very simple server script:
-- Random seed
math.randomseed(tick())
-- Loop
for i = 1, 20 do
local position = Vector3.new(math.random(-2400, 2400)/10, math.random(70,120), math.random(-2400, 2400)/10)
print(position)
wait(0.1)
end
When I run this in studio, every now and then, I get numbers that are exactly the same as the previous numbers. Here is a sample output. Note the lines in bold are the duplicates.
-205.5, 114, 238.100006
-239.399994, 98, -147.199997 (x2)
148.199997, 99, -9.69999981
-239.399994, 98, -147.199997
-71.9000015, 115, 155
-239.399994, 98, -147.199997
118.400002, 78, 172.300003
148.199997, 99, -9.69999981 (x2)
101.099998, 96, -94.0999985
-71.9000015, 115, 155
118.400002, 78, 172.300003
-232.899994, 74, -65.0999985
101.099998, 96, -94.0999985
-169.300003, 78, 234.5
-26.1000004, 76, -237.800003
148.199997, 99, -9.69999981
-235.800003, 89, 15.1999998
-71.9000015, 115, 155
Repro File Attached:
Random Number Test.rbxl (14.2 KB)
Press Run in Studio several times until you see duplicates printed.