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

Why wont this Map Changing Script Work? (I am new)

Asked by 10 years ago
script.Parent.Touched:connect(function()
                wait(1)
    for i,v in pairs(game.ServerStorage:GetChildren()) do
            if string.lower(v.Name) == "level2" then
    v.Parent = Workspace
    end
end
for i,v in pairs(game.Workspace:GetChildren()) do
if string.lower(v.Name) == "level1" then
    v.Parent = ServerStorage
                    end
           end
end)

This is suppose to change the map when the brick is touched but wont work..

2 answers

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

See what prints.

local db = true
local map1 = "level1"
local map2 = "level2"
local storage = game:GetService("ServerStorage")

if storage:findFirstChild(map1) and  storage:findFirstChild(map2) then 
    print("Both are there")
else
    print("One or both of those is nil")
    return 
end



script.Parent.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and db then
        db = false
        for i,v in pairs(storage:GetChildren()) do
            if v.Name:lower() == map2 then
                v.Parent = Workspace
            end
        end
        for i,v in pairs(Workspace:GetChildren()) do
            if v.Name:lower() == map1 then
                v.Parent = storage -- You had an error here.
            end
        end
        db = true
    end
end)




Ad
Log in to vote
-3
Answered by 10 years ago

Did you check the output window?

0
Yup R3v3r3nd 0 — 10y
0
Did you create a map? Does the script even say about changing maps? Policewings777ER 0 — 10y
0
Yes I created a map R3v3r3nd 0 — 10y
0
Poor use of an answer. User#11893 186 — 10y

Answer this question