How do I randomize maps on load

Ex: Round is over and need to load a new map from ServerStorage.Maps

How do I randomize the map that comes out? im trying math.random(v) and other stuff but I can’t seem
to figure it out.
function NewMap()
–code in here
end
EDIT: it wont let me do code block ^

-- other part in script
NewMap()

Thanks!

Its actually Pretty easy, Lets say you have a folder full of maps in the server storage, You can simply do as following:

local maps = game:GetService('ServerStorage').yourFolder:GetChildren()
local randomMap = maps[math.random(1,#maps)]
-- you can easily clone it after that and delete the current one

EDIT: for further explanation, The first variable gets all the objects inside that folder and its basically a table full of all the maps you have, The second line selects a random map utilizing the math.random function which will select a random map from the table we defined earlier from the number 1 to the number of maps

2 Likes