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

How Can I Stop Loop?

I made radio. To use it you have to type r/ . And when I type word all 11 labels in gui repeats same word. Here is lua:

local lineNum = 1

game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if msg:sub(1,2) == "r/" then
			if lineNum == 1 then
				game.Workspace.RadioLines.L1.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1
			end
			if lineNum == 2 then
				game.Workspace.RadioLines.L2.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1
			end
			if lineNum == 3 then
				game.Workspace.RadioLines.L3.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 4 then
				game.Workspace.RadioLines.L4.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 5 then
				game.Workspace.RadioLines.L5.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 6 then
				game.Workspace.RadioLines.L6.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1
			end
			if lineNum == 7 then
				game.Workspace.RadioLines.L7.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 8 then
				game.Workspace.RadioLines.L8.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 9 then
				game.Workspace.RadioLines.L9.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 10 then
				game.Workspace.RadioLines.L10.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 11 then
				game.Workspace.RadioLines.L11.Value = player.Name ..": ".. msg:sub(3)
				lineNum = lineNum + 1 
			end
			if lineNum == 12 then
				game.Workspace.RadioLines.L1.Value = player.Name ..": ".. msg:sub(3)
				lineNum = 1
			end
		end
	end)
end)

2 answers

Figured out! Just add return 0 to stop it like in other programming languages.

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