Hello! I have a list that I want to pick a random vehicle from the list and print it but I end up getting the same vehicle when I run the game. How can I make this truly random?

while true do
math.randomseed(tick())
local Common = {"Car","AnotherCar","BigCar","MinivanCar","RatherLargeCar"}
local randomchoice = Common[math.random(5)]
print(randomchoice)
wait(0.5)
end

7 comments

0

Try this: "math.randomseed(tick()) math.random()" Keep those together. It makes it really random, at least for me.

0

On which line?

0

Under the while loop, so Line 2.

0

I wouldn't recommend putting it in the loop; Seems unsafe.

0

Put it outside the loop. It might be that you are defining the seed right before using it, so you always generate the same number.

0

You all helped me answer it. Thanks! Also, if anyone just wants some rep, just submit an answer so I can accept.

0

Heads up! Right now, it seems that there's going to be a change to the function: https://devforum.roblox.com/t/a-random-feature/64517