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
wait(5)
MapOne.Visible = false
end
elseif MapRandomOne == 2 then
if MapRandomOne ~= LastNumber then
MapTwo.Visible = true
wait(5)
MapTwo.Visible = false
end
elseif MapRandomOne == 3 then
if MapRandomOne ~= LastNumber then
MapThree.Visible = true
wait(5)
MapThree.Visible = false
end
end
wait(6)
end
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
task.wait(5)
random1.Visible = false