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

How do I make a map changer script?

Asked by 10 years ago

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?

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. User#11893 186 — 10y

3 answers

Log in to vote
0
Answered by 10 years ago

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
Ad
Log in to vote
0
Answered by 10 years ago

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

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. User#11893 186 — 10y
Log in to vote
0
Answered by 10 years ago

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()

Answer this question