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

Why is this loop with a break statement not breaking?

So I'm working on an unboxing system for a game. When I test it, studio notifies me to break it, as it's been running for a long time. I don't see any reason why it's hanging. Any help here is appeciated.

	for i = 1, 1 do
		wait(Speed / 25)
		if i == 25 then
			Prize.Position = script.Parent.RightHider.Position
			Prize.Parent = script.Parent.InvisConveyor
		end
		FillerTable[i].Position = script.Parent.RightHider.Position
		FillerTable[i].Parent = script.Parent.InvisConveyor
		local A = script.ThingHandler:Clone()
		A.Parent = FillerTable[i]
		A.Disabled = false
		if i == 30 then
			break
		end
	end

If you must know, Speed is 10 seconds, FillerTable is a table of frames given by the server, RightHider is just an area with higher Z-Index so the user doesnt see items appearing. ThingHandler is just a script to delete the tiles after going past the view. Prize is just a pre-selected prize the user will get.

4 comments

0

you can't break for loops i do not think

0

You can break for loops. In fact, it is used in an example in the wikipedia.

1

The for loop you made is set to act like a do end block. it only repeats once....

0

him, it still shouldn't hang then crash my studio if it repeats once...

1 answer

for i = 1, i < 30 do
	--Code here
	--No longer need the if statement and break here
end

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