Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i make a Map Changer? I have 5 maps, and i need them to alternate, (New Spawns for Each Map)

Asked by 8 years ago

How do i make a Map Changer? I have 5 maps, and i need them to alternate, (New Spawns for Each Map)! I havent tried many codes, i just need help understanding the script! Please Help!

1 answer

Log in to vote
1
Answered by
joalars2 107
8 years ago

A fairly easy way to create a map changer is to put all of the maps into serverstorage.

Then, clone them into workspace.

local currentmap = game:GetService("ServerStorage").MapName:Clone()
currentmap.Parent = game:GetService("Workspace")

When you want to delete the map in preparation for loading another one, its as simple as just destroying it.

local currentmap = game:GetService("ServerStorage").MapName:Clone()
currentmap.Parent = game:GetService("Workspace")
wait(60)
currentmap:Destroy()

You should make the entire loading/deleting process a function, and then call that function inside some other code... For ease of access if you're doing multiple things within the script

local function LoadMap(mapName, time)
    local currentmap = game:GetService("ServerStorage")[mapName]:Clone()
    currentmap.Parent = game:GetService("Workspace")
    wait(time)
    currentmap:Destroy()
end

You can now call that function at any time, providing the map name and time requested to keep the map on, before deleting it!

local maps = {"map1", "map2", "map3"}
local waittime = 60

local function LoadMap(mapName, time)
    local currentmap = game:GetService("ServerStorage")[mapName]:Clone()
    currentmap.Parent = game:GetService("Workspace")
    wait(time)
    currentmap:Destroy()
end

while wait() do
    LoadMap(maps[math.Random(1,#maps)],waittime)
    wait(waittime)
end

Hopefully that works the way you want it to.

0
so i put that whole peice of code into a script and in workspace, Renamed all three of the Maps, map1, map2, and map3, But it still did not work, i spawned in the air and just kept on falling! What did i do wrong? PartyScripters 20 — 8y
0
Did you place the maps into "ServerStorage"? joalars2 107 — 8y
Ad

Answer this question