math.random

Is it possible to have math.random come up with decimals? Ex: 2.84 or anything like that? Because so far i have only seen it come up with whole numbers

Just using plain math.random() will return a value between 0 and 1.

If you want a higher value, you can get there easily enough, for example, (math.random()*10) will give you a value between 0 and 10 with 5 values after the decimal.

@Mark Say i wanted only three decimal places. Would that be possible?

Three decimal places. I’m not sure if it works but it should.

x = math.random(???,???)

x = x/1000

Number between 0-1
X=math.random(0,1000)/1000

For bigger numbers just multiply by bigger numbers inside the bracket, eg 0-100
X=math.random(0,100000)/1000

If you want negatives as well as positives,that’s easy
X=math.random(-100000,100000)/1000

math.random(10000)/1000 will give a value between 0 and 10 with three decimals.

print(math.random(0,100)/math.random(1,10)