# Lua math.random problem

**URL:** <https://forum.defold.com/t/lua-math-random-problem/19372>\
**Category:** Questions\
**Created:** [April 27, 2018, 2:54pm UTC](https://forum.defold.com/t/lua-math-random-problem/19372 "2018-04-27T14:54:51Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 27, 2018, 8:32am UTC](https://forum.defold.com/t/lua-math-random-problem/19372/18 "2018-10-27T08:32:48Z")

</div>

Ah, I see. Well, hmm, if you throw away the first one or two random numbers you start to get the kind of variation that is to be expected:

```
-- os.time() seems to work equally well
math.randomseed(socket.gettime()) math.random() math.random()
print(math.random(1,3))

```

Not optimal. Perhaps we can deal with this better internally in the engine…

---

_[View the full topic](https://forum.defold.com/t/lua-math-random-problem/19372)._
