I'm using math.random() to add values between 1.99 and 3.99 to player.leaderstats.Dollars.Value. However, when using math.random() the numbers were randomized, but came out as integers. Here's the code I first attempted to do this with:
client.leaderstats.Dollars.Value = client.leaderstats.Dollars.Value + math.random(1.99, 3.99)
When I realized that the numbers were being rounded, I added 2 "NumberValue" objects to the script (so... script.min, and script.max). "script.min.Value" was equal to 1.99, and "script.max.Value" was set to 3.99. Here's what I tried:
client.leaderstats.Dollars.Value = client.leaderstats.Dollars.Value + math.random(script.min.Value, script.max.Value)
The numbers were still being rounded to integers. How would I go about fixing this?
You could just do a random value between 199 cents and 399 Cents and then convert it to Dollars
Cents = math.random(199, 399) Dollars = Cents/100 client.leaderstats.Dollars.Value = client.leaderstats.Dollars.Value + Dollars
Check out this post : https://scriptinghelpers.org/questions/40983/how-do-i-make-a-mathrandom-with-decimals
Also answered by @OBenjOne
Basically get a random number, divide it by any power of 10.
In this case,
client.leaderstats.Dollars.Value = client.leaderstats.Dollars.Value + math.random(199, 399)/100