Reproduction Steps
Call Random.new(nil)
with a nil argument given.
local rand = Random.new(nil)
local randomSeed = nil
local rand = Random.new(randomSeed)
repo.rbxl (40.0 KB)
Expected Behavior
Act as all other objects behave, where an argument nil
is treated the same as no argument at all, and create a default object. As per the documentation, this should pull a random seed from elsewhere.
Actual Behavior
Throws the following error:
invalid argument #1 to 'new' (number expected, got nil)
Workaround
Use a ternary operator if randomSeed
is nil
local function getRandom(randomSeed: number?)
return randomSeed and Random.new(randomSeed) or Random.new()
end
Issue Area: Engine
Issue Type: Other
Impact: Low
Frequency: Constantly
Date First Experienced: 2023-01-17 11:01:00 (-05:00)