random

Generates a random number within a specified range.

Parameters:

  • min (number, optional): Minimum value (inclusive). Defaults to 0

  • max (number, optional): Maximum value (inclusive). Defaults to 1

Returns:

  • result (number): Random number between min and max

Example:

-- Random between 0 and 1
local chance = ps.random()
-- Result: 0.xxx

-- Random dice roll
local dice = ps.random(1, 6)
-- Result: 1, 2, 3, 4, 5, or 6

-- Random spawn coordinates
local x = ps.random(-1000, 1000)
local y = ps.random(-1000, 1000)

-- Random reward amount
local reward = ps.random(100, 500)

Last updated