0

# How do I make a map changer?

Please could you help me with this because i want to ake a fighting game and i need to change map every 20 mins

0

This is actually easy. I use this with trains to spawn random trains to pass in railfanning games. I can give you a script to do exactly what you want it to do. All you have to do is make the maps, put the maps as separate models with particular names in Lighting, and put its exact name into the script. Then set your time for 20 minutes. (time is set in seconds though, so be careful with that.) If you do that right, every 20 minutes, the map will change, and a random map of your list will be chosen. Sometimes it'll repeat, but that's because it is totally random. Let me know if you would like the script.

0

You can make a table contains the map names like this: maps = {"map1", "map2", "map3"} all of they need to be in the same game's location (like workspace, lighting etc.)and then make a function that passes a variable into the table and get a random one, from there you put a wait(60 * 20) (second * minutes = minutes in seconds). There's an example:

maps = {"carentan", "yogga", "funny" } --Random names FTW!!!!
mapPath = game.Lighting--The maps location, usually is Lighting
local randomMap
function someRandomFunction()
randomMap = maps [math.random(1, #maps)]
local selRandomMap = randomMap:Clone().Parent = game.Workspace
wait(60 * 20)
randomMap = nil
someRandomFunction()
end


If want the same code that I use then there you are:

_G.startGame = function()
local serverdata = game.ServerStorage:FindFirstChild("ServerData")
local prototype = serverdata:FindFirstChild("Prototype")
prototype.Value = game.Players:GetChildren()[math.random(1, #game.Players:GetChildren())].Name
changeStatusText("Starting game, the prototype is " .. prototype.Value)
wait(2)
local randMap = maps[math.random(1, #maps)]
local selMap = game.ServerStorage:FindFirstChild(randMap):Clone()
selMap.Parent = game.Workspace
wait(5)
changeStatusText("The selected map is " .. selMap)
wait(3)
changeStatusText("Teleporting everyone to the map...")
local spawns = {"1", "2", "3"}
local enemySpawn = randMap.EnemySpawn
[...]
end

0
Mauvn 100
7 years ago

This is a pretty long script but it helps!

map1 = game.Lighting:findFirstChild("MyMapName1") -- Change Here Your First Map Name.
map2 = game.Lighting:findFirstChild("MyMapName2") -- Change Here Too.
map3 = game.Lighting:findFirstChild("MyMapName3") --Same here
map4 = game.Lighting:findFirstChild("MyMapName4") --Same here
map5 = game.Lighting:findFirstChild("MyMapName5") --Same here
map6 = game.Lighting:findFirstChild("MyMapName6") --Same here
map7 = game.Lighting:findFirstChild("MyMapName7") --Same here
map8 = game.Lighting:findFirstChild("MyMapName8") --Same here
map9 = game.Lighting:findFirstChild("MyMapName9") --Same here
map10 = game.Lighting:findFirstChild("MyMapName10") --Same here
time = 300 -- This Is The Time When The Map Changes.
clone = map1:clone() --Dont Edit Anything.
clone2 = map2:clone()
clone3 = map3:clone()
clone4 = map4:clone()
clone5 = map5:clone()
clone6 = map6:clone()
clone7 = map7:clone()
clone8 = map8:clone()
clone9 = map9:clone()
clone10 = map10:clone()
wait()
map1:remove()
map2:remove()
map3:remove()
map4:remove()
map5:remove()
map6:remove()
map7:remove()
map8:remove()
map9:remove()
map10:remove()
while true do
local map = clone:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone2:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone3:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone4:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone5:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone6:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone7:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone8:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone9:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
local map = clone10:clone()
map.Parent = game.Workspace
wait(time)
map:remove()
end


Hope i helped! :)