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

What is the Break Variable?

I saw it on a Lua Teaching Game, I didnt Know that it was a Variable, I think from its name it works like Remove, or Destroy, Except it Breaks things, Am I correct if not Give me an example?

1 answer

break is not a variable, it is a 'keyword', which is why it is colored blue in the script editor.

break is used to, as the name implies, break out of a loop before its condition would otherwise allow.

For example:

local var = 0
while var < 20 do
	var = var + 1
	wait()
end

and

local var = 0
while true do
	var = var + 1
	if var >= 20 then
		break
	end
end

are functionally identical.

A practical use of break is quitting a Murder-type game's loop when the Murderer is killed or otherwise leaves the game.

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