I have made an effort to try and figure it out and I can't. I'm hoping someone will be able to help me else I'll be stuck on this problem for awhile.
Here is the code. Does anyone have any suggestions to stop it from choosing the same map twice in a row?
function chooseMap() --Chooses Map (IN-PROGRESS) local mapChoice = math.random(1,3) if mapChoice == 1 then print("Map 1 got chosen!") local map = game.ServerStorage.Maps.Map1:clone() map.Parent = game.Workspace map:MoveTo(Vector3.new(100,100,100)) --load map 1 elseif mapChoice == 2 then print("Map 2 got chosen!") local map = game.ServerStorage.Maps.Map2:clone() map.Parent = game.Workspace map:MoveTo(Vector3.new(100,100,100)) --load map 2 elseif mapChoice == 3 then print("Map 3 got chosen!") local map = game.ServerStorage.Maps.Map3:clone() map.Parent = game.Workspace map:MoveTo(Vector3.new(100,100,100)) --load map 3 end end
I tried to simplify the code along with your request. What I did is I added a condition that required the map to be different from the last map chosen, then setting that map to be the last map chosen.
local lastMap = 0 function ChooseMap() local mapChoice repeat mapChoice = math.random(1,#game.ServerStorage.Maps:GetChildren()) until mapChoice~=lastMap lastMap = mapChoice local map = game.ServerStorage.Maps["Map"..mapChoice]:Clone() -- Your loading code here. end