Math.random always return the same number?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to get a random value on a loop

  1. What is the issue? Include screenshots / videos if possible!

This is the first time I encounter this issue with math.random, I never had this problem before, so I have no idea why it bug for this loop specifically ?

  1. What solutions have you tried so far? Did you look for solutions on the Creator Hub?

Searched on internet, also added some timer, but the result didn’t changed.

Ok so my problem basically is, I have math.random that always return the same value

for i, v in pairs(GameTable["players"]) do
	warn("PICKING A RANDOM NUMBER: "..math.random(1,1000).."")
	InitPlayer(i, v.bot)
end

On the example above, the math.random(1,1000) returned 7 times in row the value “637”.
Everytimes I rerun this function, it give me 7 times the exact same number.

Isn’t this supposed to give me 7 different numbers ???

1 Like

try using: setseed(tick())
this can fix your code possibly

4 Likes

It worked, thank you very much.

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