การใช้ math.random

 ประโยชน์ของ random เอาไว้สุ่มตัวเลข ขึ้นมาเช่น


-- สุ่มเลขตั้งแต่ [0, 1)
local rand1 = math.random()

-- สุ่มเลขตั้งแต่ 1 ถึง 10
local rand2 = math.random(10)

-- สุ่มเลขตั้งแต่ 10 ถึง 100
local rand3 = math.random(10, 100)

ความคิดเห็น