Math.random generates same value each time I join

I’m using an infinite terrain generator plugin and it works pretty good. The problem is that it generates the same map over and over. I’ve asked for help on the discord server and I was told to generate a new seed each time by using math.random().

I’m using this script to test the math.random() stuff but whenever I join, the same values get printed

math.randomseed(tick())
math.randomseed(1)

local randomseed1 = math.random(10000, 95000)
math.randomseed(2)
local randomseed2 = math.random(10000, 95000)
math.randomseed(3)
local randomseed3 = math.random(10000, 95000)

print('Random seed 1: '.. tostring(randomseed1).. 'Random seed 2: '.. tostring(randomseed2).. 'Random seed 3: '.. tostring(randomseed3))
1 Like

Only the first is necessary.

math.randomseed(tick())

local randomseed1 = math.random(10000, 95000)
local randomseed2 = math.random(10000, 95000)
local randomseed3 = math.random(10000, 95000)

print('Random seed 1: '.. tostring(randomseed1).. ' Random seed 2: '.. tostring(randomseed2).. ' Random seed 3: '.. tostring(randomseed3))
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.