How to stop a math.random call from picking numbers from another math,random call

local MapOne = script.Parent.MapOne
local MapTwo = script.Parent.MapTwo
local MapThree = script.Parent.MapThree

while true do
	local MapRandomOne = math.random(1,3)
	local MapRandomTwo = math.random(1,3)
	local LastNumber = nil
	if MapRandomOne == 1 then
		if MapRandomOne ~= LastNumber then
			MapOne.Visible = true
			MapOne.Visible = false
	elseif MapRandomOne == 2 then
		if MapRandomOne ~= LastNumber then
			MapTwo.Visible = true
			MapTwo.Visible = false
	elseif MapRandomOne == 3 then
		if MapRandomOne ~= LastNumber then
			MapThree.Visible = true 
			MapThree.Visible = false

How do i make it so that map random 2 can only pick numbers that have not been chosen by map random 1?

easiest way is to keep track of what map1 rolled, then check if the map2 roll is the same as map1 roll. If it’s not the same then continue, but if it’s the same then just roll again until it’s not the same number

-- get all the maps and save them into a table
local maps = script.Parent:GetChildren()
-- remove a random map from the table and save it into random1
local random1 = table.remove(maps, math.random(#maps))
-- select a random map from the table no need to remove it because we wont be selecting any more after this
local random2 = maps[math.random(#maps)]

-- print the 2 random maps
print(random1.Name, random2.Name)

random1.Visible = true
random1.Visible = false

why not instead of choosing 2 random maps, you choose 1 to remove it from the list and the 2 remaining get chosen ?