How can i get a range of numbers?

I would like to get a range of numbers.
i want to do math.random and check if the random number is in the range.
i have no idea how to do this.
I haven’t been able to find a solution on here.

Thanks.

just do:

local num1 = (minimum range number)
local num2 = (maximum range number)

local randomNum = math.random(minRandomRange, maxRandomRange)

if num1 <= randomNum <= num2 then
     --Code
end

This wont work (i think it does work in other programming languages tho, but not in roblox/lua). It’s like saying

if boolean <= num2 then

end

You can do this which doesn’t use < or >.

if math.clamp(randomNum,num1,num2) == randomNum then

end
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.