Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

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?

0

Did you place the maps into "ServerStorage"?

This discussion is preserved as it was. New answers, comments, and votes are closed.