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

Why does math.random() always give me zero and never any other number?

Asked by 4 years ago

Here is what I wrote:

local pos = math.random(0.06,0.65)

3 answers

Log in to vote
1
Answered by 4 years ago

math.random() only takes integers. If you wish to have a randomly generated decimal you need to divide the generated integer by a certain number. For example, to get a random decimal from 0.06 to 0.65:

local num = math.random(6, 65) / 100
0
please use this, this is correct lol DevScripting 92 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Your script is correct.

0
But it doesn't work it prints out 0 every time MaciBoss1950 16 — 4y
Log in to vote
0
Answered by 4 years ago

math.Random only supports integers. You can't have decimals.

Answer this question