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

Help With Random Numbers?

Asked by
Scootakip 299 Moderation Voter
8 years ago
while true do
    print(math.random(.1, 1))
    wait(1)
end

This script is kinda broken. It is supposed to choose a random number from .1 to 1, but it seems as if Roblox isn't capable of doing that as it only can choose 0 and 1. Someone help with this issue? Is it even fixable?

1 answer

Log in to vote
2
Answered by
Im_Kritz 334 Moderation Voter
8 years ago

Yeah, you can't choose a number from .1 to 10 by using math.random. To fix this, all you got to do is use a little bit of basic math division.

The code below chooses a random number from 1 to 10 then divide it by 10 to get it to the decimal you wanted:

while true do
    print(math.random(1, 10) / 10)
    wait(1)
end
0
Thanks for the idea, I can't believe I didn't think of that. Scootakip 299 — 8y
Ad

Answer this question