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!
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.