if game.Workspace.Map.LeftDoor.ClickPart.Closed.Value == true and game.Workspace.Map.RightDoor.ClickPart.Closed.Value == true then
wait(1)
if game.Workspace.Map.LeftDoor.ClickPart.Closed.Value == true and game.Workspace.Map.RightDoor.ClickPart.Closed.Value == true then
kill = false
for _, v in pairs(game.Workspace.Map.ShadowBonnieDoor:GetChildren()) do
v.Transparency = 1
end
game:GetService("ReplicatedStorage").Move:FireClient(game:GetService("Players"):GetPlayerFromCharacter(script.Parent),"Shadow Bonnie")
break
end
end
Just answer yes or no, I want it to ignore the if statements.
Your break is not inside any loop in the snippet you showed, so as far as I can tell it will do nothing or error.
More info:
If the program hits a break, it will jump to the line right after the tightest loop that contains the break.
for outer = 1, 3 do
print("outer")
for inner = 1, 5 do
print(" inner")
if inner == 2 then break end -- breaks out of the 'inner' loop but not the 'outer'
end
end
I know mostly how break works, and it is inside of the loop but I just didn’t show it in the script above. I just wanna know will it ignore the “end” part of the if statement, so it will break out of every if statement no matter how many it is inside.
What I’m asking is, will the break work like this?
for i = 0, 2, 1 do
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
break
end
end
end
end
end
end
end
--breaks here
end
Break won’t function here, it only functions within loops, and will bypass all if statements and only check if it’s in a loop. (Replied to your first message)
for example:
for i = 1, 10 do
if i == 4 then
break
end
print("No Way")
end
console:
No Way
No Way
No Way
It doesn’t matter if there is an if statement, it will ignore the if statement and break the loop.
and yes, that’d work. Because it transcends if statements and only looks at the loop it’s in.
Ok I get your question, it ignores all the ends yes, the loop will end on Break, and ignore all the ends.
Sorry I didn’t understand your question at first
It’ll look like this:
for i = 0, 2, 1 do
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
break --Breaks here
end
end
end
end
end
end
end
end
I said just answer with a yes or no, please don’t respond telling me how break works, because I already know. The code I showed as an example is inside a loop (for i loop) and I just showed a small portion of it. I wanna know if break will work like this, and this is just an example:
for i = 0, 2, 1 do
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
if this = that then
break
end
end
end
end
end
end
end
--breaks here
end
Yes. It jumps to the end. If you had statements in between all those ends they would be ignored.
for i = 1, 10 do
print(">")
if i == 1 then
print("> a")
if i == 1 then
print("> b")
if i == 1 then
print("> c")
break
print("< c")
end
print("< b")
end
print("< a")
end
print("<")
end
print("done")
When the break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.
If you are using nested loops (i.e., one loop inside another loop), the break statement will stop execution of the innermost loop and start executing the next line of code after the block.