How do I script a pick a random map script?

Hay Developers, I was wondering if you guys could help me make a script that pick a random map from game.Lighting? I have never done this before and have no idea what to do. Please help!

1 Like

Unrelated, but I’d prefer storing your maps inside ServerStorage instead for secure purposes

You could just simply put the Maps in a Folder, then call GetChildren() which would return a table of all the maps inside that Folder

The main key is using math.random(), which would then randomly choose 1 out of all the possible maps there is

local Maps = game.Lighting.Maps:GetChildren()

local RandomMap = Maps[math.random(1, #Maps)] 
print(RandomMap)

if RandomMap then
    --Do something here
end