Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help With Random Numbers?

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

✓ Accepted answer

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

1 comment

0

Thanks for the idea, I can't believe I didn't think of that.

This discussion is preserved as it was. New answers, comments, and votes are closed.