So I’m kind of inexperienced in scripting.
I’ve written this script (a lot of copy and paste involved) and what it is supposed to do is teleport players to a set of coordinates depending on the map that is chosen (the maps are in lighting). It then gives players a random spawn point in that map. (How I got the coords was by putting down parts and copy/pasting the coords of the parts. The “elseif” at line 70 gets underlined red and the script wont work. I can’t find a way around or to fix it, so yeah. If I remove the “elseif” at line 70, the next “elseif” gets an error and so on. How can I fix this?
Maps = game.Lighting.Maps:GetChildren()
while true do
wait(10)-- map switch cooldown time
Chance = Maps[math.random(1, #Maps)]
Chance.Parent = game.Workspace
wait(60)-- Time the map stays
Chance.Parent = game.Lighting
end
--Teleportation to maps garbage
if Chance == 1 then
--Snowball Fight FFA
chance2 = math.random(1,5)
if chance2 == 1 then
--Teleport to snowball FFA map
target = CFrame.new(67.609, 3.5, -83.022 ) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
elseif chance2 == 2 then
--Teleport to snowball FFA map
target = CFrame.new(-104.778, 3.5, 105.315 ) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
elseif chance2 == 3 then
--Teleport to snowball FFA map
target = CFrame.new(48.69, 3.5, 62.513) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
elseif chance2 == 4 then
--Teleport to snowball FFA map
target = CFrame.new(-29.619, 3.5, 8.999) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
elseif chance2 == 5 then
--Teleport to snowball FFA map
target = CFrame.new(-136.95, 3.5, -80.76) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
wait(60)
--Lobby teleport
target = CFrame.new(-54.313, 385.384, 46.534) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
end
if Chance == 2 then
--Teleport to crumbling snow parkour
target = CFrame.new(-136.95, 3.5, -80.76) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
wait(60)
--Lobby teleport
target = CFrame.new(-54.313, 385.384, 46.534) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
if Chance == 3 then
chance3 = math.random(1,4)
if chance3 == 1 then
--Teleport to spleef runner
target = CFrame.new(-763.853, 66.003, -11.062) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
elseif chance3 == 2 then
--Teleport to spleef runner
target = CFrame.new(-692.911, 66.003, 67.276) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
elseif chance3 == 3 then
--Teleport to spleef runner
target = CFrame.new(-772.005, 66.003, 129.839) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
elseif chance3 == 4 then
--Teleport to spleef runner
target = CFrame.new(-844.768, 66.003, 44.773) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
wait(60)
--Lobby teleport
target = CFrame.new(-54.313, 385.384, 46.534) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
--Make sure the character exists and its HumanoidRootPart exists
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
--add an offset of 5 for each character
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
end
end
end
end
Typically I’m a builder.