Here's the script:
local players = game.Players:GetChildren()
local maps = game.Lighting.Maps:GetChildren()
local currentmap = game.Workspace:WaitForChild("CurrentMap")
local chosenmap = script:WaitForChild("ChosenMap")
local spawner = game.Workspace:WaitForChild("Spawn")
local choices = {}
function chooseMap()
for i = 1,#maps do
if maps[i]:isA("Model") then
table.insert(choices,maps[i])
end
end
local picked = math.random(1,#maps)
chosenmap.Value = choices[picked].Name
end
function loadMap()
local map = game.Lighting.Maps:FindFirstChild(chosenmap.Value)
map:Clone().Parent = currentmap
end
function deleteMap()
for i,v in pairs(currentmap:GetChildren()) do
if v:isA("Model") then
v:Destroy()
end
end
end
function teleportPlayers()
for i,v in pairs(players) do
v.Character.HumanoidRootPart.CFrame = currentmap:FindFirstChild(chosenmap.Value).Spawn*CFrame.new(math.random(5,10),0,math.random(5,10))
end
end
while true do
wait(3)
chooseMap()
loadMap()
wait(1)
teleportPlayers()
wait(10)
deleteMap()
teleportPlayers()
end
There is a folder named CurrentMap, and a string value name "ChosenMap" inside the script, all of which is in the workspace.
The two maps are in a group called "Maps" and put into the lighting.
There aren't any spawn locations, just parts named spawn.

1 comment
Sorry it's pretty complicated