Randomized Map

Gets a random map that you made and places it into workspace.

by jigwv

Author Avatar

What you need,

You need to know,

Programming,

First add you maps to a folder or model, which ever you like best, and rename it. Then put that into ReplicatedStorage. Next insert a script into ServerScriptService and write the following lines of code in the script

local MapsHolder = game.ReplicatedStorage:WaitForChild("MapStorage")

local function GetNewMap()
    if #MapsHolder:GetChildren() then
        local RandomMap = MapsHolder:GetChildren()[math.random(#MapsHolder:GetChildren())]
        return RandomMap
    else
        print("No maps")
    end
end

Technically that is what you need, but if you want to add that map into workspace, you add this.

local CurrentMap = nil

while wait(15) do
    if CurrentMap then
        local Map = GetNewMap()
        if Map then
            Map.Parent = game.Workspace
        end
        CurrentMap:Destroy()
        CurrentMap = Map
    else
        local Map = GetNewMap()
        if Map then
            Map.Parent = game.Workspace
        end
        CurrentMap = Map
    end
end

What this does is every 15 seconds, a new map is recieved and replaces the old one.

View in-game to comment, award, and more!