0

# How to use Math.random? I forgot it

Hey there! I totally forgot how math.random worked.

Could anyone explain this to me?

I need it for a FOV changer that just changed the fov at random moments.

2
Xapelize 2326
2 years ago

A math.random(min,max) is a CODE for getting a random number.

print(math.random(1,10))


Output :

8

This CODE means to print a number that 1 to 10. Let's do another code :

print("math.random(1,10)")


Output :

math.random(1,10)

OH, WHAT'S WRONG? Aha, ignore the " " in the print!

Output :

7

etc :

local number1 = math.random(1,10)

print("OMG, THE NUMBER IS ".. number1)


Output :

OMG, THE NUMBER IS 4

Ok, thanks for watching, have a nice day and happy coding :) If you have any question comment below :D

 local r=math.random(1,4)