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

math.randomseed only returns nil?

Asked by 8 years ago

I ran this:

print(math.randomseed(5))   

It output a blank space, which is a nil value. This is preventing me from doing math.randomseed(tick()). Help?

1 answer

Log in to vote
3
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

math.randomseed(tick()) is just done to change the seed of the (pseudo)random number generator. What you're looking for is math.random:

math.randomseed(tick());

local randomNumberBetweenOneAndFive = math.random(5);

Read more about random numbers.

Hope this helped.

Ad

Answer this question