Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to print a random number in a table?

Asked by
FiredDusk 1466 Moderation Voter
7 years ago

The code does print but I feel that it picks the same number it printed before more often. I feel as if this code does not print too random.

math.randomseed(os.time())

Entered = {

    '1',
    '2',
    '3',
    '4',
    '5',
    '6',
    '7',
    '8',
    '9'

}

--for i,v in pairs(Entered) do
    local Winner = Entered[math.random(1,#Entered)]
--end
print(Winner)

2 answers

Log in to vote
0
Answered by 7 years ago

It is simple in the past I have asked a question like this:https://scriptinghelpers.org/questions/33467/random-and-arrays

Remember to search if someone has answered the question or not and to accept the answer.

Ad
Log in to vote
-1
Answered by 7 years ago

Try math.randomseed(tick(0))

Answer this question