Random Map Chooser

I made a random map chooser for a project and I’m not sure where I’m supposed to put it. The code is in a regular script in Workspace. Is it supposed to be another script?

It doesn’t seem like any part of your script is dependent on its location, so I’d put it in ServerScriptService, which acts as a general spot to store server-side scripts.

Also, it seems that the pickMap() function isn’t actually loading the map. Try changing it to this:

local function pickMap()
    local mapList=maps:GetChildren() --get available maps
    local selectedIndex=math.random(1,#maps) --get a random number
    local map=mapList[selectedIndex]:Clone() --get the map at the random position and clone it
    map.Parent=workspace --drop it into Workspace
    local mapName=map.Name --store the map name, since we're about to overwrite it
    map.Name="Map" --rename it
    return mapName --return the map's name
end
1 Like

map and selectMap() are not defined.

1 Like

In an unrelated note, there seems to be a few problems with your code:

What is the map variable supposed to represent? It does not seem to be satisfied with the code you have presented. Also, selectMap does not seem to be defined.

@REALTimothy0812 nice typing skills :eyes: , beat me to it.

Is there any particular script it’s supposed to be in?

Like I said, it doesn’t matter where it is for the most part, so you should put it in ServerScriptService.

Scripts will execute the same regardless of where they run (as long as they run), however script.Parent will be different.