Random Outcome Using math.random Doesn't Work

I want to make a random outcome happen, and my current system uses math.random
I have 3 outcomes I want to happen, but my if then script doesn’t work, and only responds to else!

if math.random(1,3) == 1 then
	
	-- outcome 1
	
elseif math.random(1,3) == 2 then
	
	-- outcome 2
	
elseif math.random(1,3) == 3 then
	
	-- outcome 3
	
end

When replacing the third elseif with only an else, it only runs that outcome. If I keep all 3 as elseif, no outcomes run!

Try it like this, so that your math.random only runs once:

local number = math.random(1,3)

if number == 1 then
	
	-- outcome 1
	
elseif number == 2 then
	
	-- outcome 2
	
elseif number == 3 then
	
	-- outcome 3
	
end
5 Likes