Hello! I am using math.random() for uis. But instead of returning 1,2, or 3, I want to make it return decimal numbers like 1.2,2.1, etc
So, how do i make that?
3 Likes
local currentnumber = math.random(0,100) / 10
6 Likes
local function lerp(a,b,t)
return a + (b - a) * t
end
local min,max = 10,50
print(lerp(min,max,math.random()))
math.random() is just a random decimal number between 0 and 1. So using lerp function we can get a random decimal value between 10 and 50.
2 Likes
I think that the proper way to do it could be using Random.new():
local decNumb = Random.new():NextNumber(1, 10)
warn(decNumb)
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.