Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script skipping lines?

So I'm having a problem with my script. It keeps skipping lines. The code is done below and it tells you where it keeps skipping. I'm sure it's some problem with where my "ends" are but I'm not sure. Any help?

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")
wait(3)
	
	while true do
	
	Song = Instance.new("Sound")
	Song.Parent = workspace
	Song.Volume = 1
	Song.Looped = false
	Assets = {274504661,346191865,263966756,220964582,362105653}
	for _, asset in ipairs(Assets) do
	game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end
	Song.SoundId = "http://www.roblox.com/asset/?id=" ..Assets[math.random(1,#Assets)]
	Song:Play()
	
-- Intermission
	for i = 30,0,-1 do
		status.Value = "INTERMISSION: "..i
		wait(1)
		
	end

-- Round
status.Value = "CHOOSING THE MAP. [LAG]"
wait(0.5)
status.Value = "CHOOSING THE MAP.. [LAG]"
wait(0.5)
status.Value = "CHOOSING THE MAP... [LAG]"
wait(0.5)
local num = math.random(1,2)
if num == 1 then
	game.Lighting.SampleMap:Clone().Parent = game.Workspace
	status.Value = "SAMPLE MAP! MADE BY: ICYWYVERN!"
	wait(2)
	target = CFrame.new(13.153, -126.708, 357.876)
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
      player.Character.Torso.CFrame = target + Vector3.new(0, i * 0, 0)
end
end
if num == 2 then
	game.Lighting.SampleMap:Clone().Parent = game.Workspace
	status.Value = "SAMPLE MAP! MADE BY: ICYWYVERN!"
	wait(2)
	target = CFrame.new(13.153, -126.708, 357.876)
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
      player.Character.Torso.CFrame = target + Vector3.new(0, i * 0, 0)
end
end
-- It completely skips everything after this line and starts again
wait(1)
Song:stop()

wait(2)
game.Workspace.TornadoSirens:play()
wait(0.1)
for i = 40,0,-1 do
	status.Value = "TIME TO PREPARE: "..i

wait(1)

game.Workspace.Round:Play()
game.Lighting.Clouds:Clone().Parent = game.Workspace
wait(2)
game.Lighting.Tornado:Clone().Parent = game.Workspace
for i = 120,0,-1 do
	status.Value = "TIME LEFT: "..i
	wait(1)
game.Workspace.Round:Play()
status.Value = "GAME OVER"
game.Workspace.Round:Stop()
wait(1)
end
	end
   		end
			end
				end




1 answer

✓ Accepted answer

Fix your indentation. Seriously.

The script isn't skipping any lines. You just can't see where the problem is because of how your script looks.

If you indent your code correctly, debugging becomes a lot easier. After indenting, I was able to see the problem.

local replicatedstorage = game:GetService("ReplicatedStorage")
local status = replicatedstorage:WaitForChild("StatusValue")
wait(3)

while true do
	Song = Instance.new("Sound")
	Song.Parent = workspace
	Song.Volume = 1
	Song.Looped = false
	Assets = {274504661,346191865,263966756,220964582,362105653}
	for _, asset in ipairs(Assets) do	
		game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
	end
	Song.SoundId = "http://www.roblox.com/asset/?id=" ..Assets[math.random(1,#Assets)]
	Song:Play()

    -- Intermission
	for i = 30,0,-1 do
		status.Value = "INTERMISSION: "..i
		wait(1)
	end

    -- Round
	status.Value = "CHOOSING THE MAP. [LAG]"
	wait(0.5)
	status.Value = "CHOOSING THE MAP.. [LAG]"
	wait(0.5)
	status.Value = "CHOOSING THE MAP... [LAG]"
	wait(0.5)
	local num = math.random(1,2)
	if num == 1 then
		game.Lighting.SampleMap:Clone().Parent = game.Workspace
		status.Value = "SAMPLE MAP! MADE BY: ICYWYVERN!"
		wait(2)
		target = CFrame.new(13.153, -126.708, 357.876)
		for i, player in ipairs(game.Players:GetChildren()) do
			if player.Character and player.Character:FindFirstChild("Torso") then
				player.Character.Torso.CFrame = target + Vector3.new(0, i * 0, 0)
			end
		end
		if num == 2 then
			game.Lighting.SampleMap:Clone().Parent = game.Workspace
			status.Value = "SAMPLE MAP! MADE BY: ICYWYVERN!"
			wait(2)
			target = CFrame.new(13.153, -126.708, 357.876)
			for i, player in ipairs(game.Players:GetChildren()) do
				if player.Character and player.Character:FindFirstChild("Torso") then
					player.Character.Torso.CFrame = target + Vector3.new(0, i * 0, 0)
				end
			end
			-- It completely skips everything after this line and starts again
			wait(1)
			Song:stop()

			wait(2)
			game.Workspace.TornadoSirens:play()
			wait(0.1)
			for i = 40,0,-1 do
				status.Value = "TIME TO PREPARE: "..i
				wait(1)

				game.Workspace.Round:Play()
				game.Lighting.Clouds:Clone().Parent = game.Workspace
				wait(2)
				game.Lighting.Tornado:Clone().Parent = game.Workspace
				for i = 120,0,-1 do
					status.Value = "TIME LEFT: "..i
					wait(1)
					game.Workspace.Round:Play()
					status.Value = "GAME OVER"
					game.Workspace.Round:Stop()
					wait(1)
				end
			end
		end
	end
end

As you can see, it checks if num == 1, runs some code and then (only if num == 1), it checks if num == 2 to run the part of the code that is "skipping". I'm going to leave it up to you to fix this how you see fit.

From this point on, indent your code correctly. Hope this helped.

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