So I just made this as an example, but the concept is the same.
How would I break this while loop without an error??
while true do if 2 > 1 then --Always True break end wait(1) end
This concept is in my game script. The output says "end" expected near "if" at line [LINENUMBER], [LINENUMBER] being the line number of my if statement.
The problem is, there ARE enough ends. There are 2 ends; 1 for the if statement, 1 for the while loop. I will have to remake my entire game script if I can't find out a way. In the game script, the if statement is actually needed, and the break HAS to be inside of the if statement.
What are you trying to accomplish here by breaking the while loop? I will need a bit more of your script to be able to understand the point of the while loop in the first place.
Use a variable instead of true. Once run is 'false', the while do statement will no longer be true and end the loop. You can return to the loop when run is set to 'true' again
local run = true while run do if 2 > 1 then -- Always true run = true -- When run is 'false' the loop will break end end