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 script?

So, I know what

game.Lighting.TimeOfDay = 21.00 means, and I want to learn those bigger scripts, but I get SO CONFUSED WHEN I DO!! I want to create a map changer, but I know

game.Lighting.Map.Insert = 5.00 wait (25) game.Lighting.Map1.Insert 5.00 wait (25) end

Won't work. Can anyone please help me?

1 comment

0

You need to title your question appropriately. "I know parts of it" does not tell us anything about what you want to know about, and it isn't even a question.

3 answers

✓ Accepted answer

What I usually do for map changers is to put the maps inside a Configuration called "Maps" that is inside the ServerStorage. I then have a variable that keeps track of which map is in Workspace. Then I can reparent the maps however I want. It looks like this:

CurMap = nil

function SwitchMap(MapName)
	for _,Map in pairs (game:GetService("ServerStorage").Maps:GetChildren()) do
		if MapName == Map.Name then
			if CurMap then
				CurMap.Parent = game:GetService("ServerStorage").Maps
				Map.Parent = game.Workspace
				CurMap = Map
		end
	end
end

Oh. I was totally wrong. I'm brand new to scripting, and thank you!

1 comment

0

This is not an answer to the question and should not be here. Delete it or you will lose reputation when it is deleted.

Hello,

There is a similar question HERE. Perhaps your answer could be in there as well.

What you would need to do: Put all the maps into Lighting/ServerStorage

Put all the maps into a table, use math.random, and then load it into Workspace.

A script if you want it:

--[[
All you need to do is put all the maps into Lighting, and name them "Map" + a random number
Example:
> Lighting
-->Map1
-->Map2
etc
]]--
maps = {}

function LoadMaps()
	for i,v in pairs(game.Lighting:GetChildren()) do
		if string.lower(string.sub(v,1,3)) == "map" then
			table.insert(maps, v.Name)
		end
	end
end

LoadMaps()

function SelectMap()
	local n = math.random(1,#maps)
	local map = game.Lighting:FindFirstChild(maps[n])
	local newmap = map:Clone()
	
	newmap.Parent = game.Workspace
end

SelectMap()

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