So I'm really new to scripting and am trying to make a simple minigame to kickstart me. I have 2 maps, and when I keep out the script for the 2nd map it works fine. However, when I put in the script for the second map, the entire script breaks and I don't know what the problem is. Hopefully this isn't too long for help.
m = Instance.new('Message', workspace)
h = Instance.new('Hint', workspace)
local sword = game.Lighting.ClassicSword:Clone()
num = math.random(1,2)
map = game.Lighting.SF:Clone()
map2 = game.Lighting.Obby:Clone()
players = game.Players:GetChildren()
while true do
wait(1)
for i = 5, 1, -1 do
h.Text = "Choosing map in: "..i
wait(1)
end
h:Remove()
if num == 1 then -- if the first map is picked
h = Instance.new('Hint', workspace)
m.Text = "Map Number "..num.." Has Been Chosen!"
wait(3)
m.Text = "Sword Fight, Created by EternallySpeedy"
wait(3)
m.Text = "Be the last one alive!"
m:Remove()
wait(3)
h.Text = "Loading Map..."
wait(5)
map.Parent = game.Workspace -- loading the map
map.Name = "Map"
map:MakeJoints()
h.Text = "Teleporting Players..."
wait(3)
h:Remove()
target = Vector3.new(48.7, 0.5, 32.455) -- teleporting the players
for i, v in pairs(game.Players:GetChildren()) do
v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0))
m = Instance.new('Message', workspace)
h = Instance.new('Hint', workspace)
m.Text = "3"
wait(1)
m.Text = "2"
wait(1)
m.Text = "1"
wait(1)
m.Text = "Begin!"
wait(1)
m:Remove()
sword:Clone().Parent = game.Players.LocalPlayer.Backpack
end
for i = 60, 1, -1 do
h.Text = "Round ends in: "..i -- countdown until the round is over
wait(1)
end
h.Text = "The round is over."
wait(1)
map:Remove()
wait(5)
end
for i = 15, 1, -1 do -- countdown until the loop restarts
h.Text = "Intermission: "..i
wait(1)
end
m:Remove()
h:Remove()
m = Instance.new('Message', workspace)
h = Instance.new('Hint', workspace)
end
if num == 2 then -- If the second map is picked
h = Instance.new('Hint', workspace)
m.Text = "Map Number "..num.." Has Been Chosen!"
wait(3)
m.Text = "Obby 1, Created by EternallySpeedy"
wait(3)
m.Text = "Be the first to finish!"
m:Remove()
wait(3)
h.Text = "Loading Map..."
wait(5)
map2.Parent = game.Workspace -- loading the map
map2.Name = "Map2"
map2:MakeJoints()
h.Text = "Teleporting Players..."
wait(3)
target = Vector3.new(48.7, 0.5, 10) -- teleporting players
for i, v in pairs(game.Players:GetChildren()) do
v.Character.Torso.CFrame = CFrame.new(target + Vector3.new(0, i * 5, 0))
m = Instance.new('Message', workspace)
h = Instance.new('Hint', workspace)
m.Text = "3"
wait(1)
m.Text = "2"
wait(1)
m.Text = "1"
wait(1)
m.Text = "Begin!"
wait(1)
m:Remove()
for i = 60, 1, -1 do -- countdown until the round is over
h.Text = "Round ends in: "..i
wait(1)
end
h.Text = "The round is over."
wait(1)
map2:Remove()
wait(5)
end
for i = 15, 1, -1 do
h.Text = "Intermission: "..i -- countdown until the loop restarts
wait(1)
end
m:Remove()
h:Remove()
m = Instance.new('Message', workspace)
h = Instance.new('Hint', workspace)
end

2 comments
I found a problem. Try moving your maps to ServerStorage. Lighting used to be a good place to put items like that, but ServerStorage is more secure and more reliable. If that doesn't work then I'll look at my minigame script and see what another problem might be. :D
It's not that, I changed the if num == 2 to elseif num == 2, but there is an error. It now says, "Expected , got elseif"