Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this loop with a break statement not breaking?

Asked by
H4X0MSYT 536 Moderation Voter
6 years ago
Edited 6 years ago

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.

0
you can't break for loops i do not think abnotaddable 920 — 6y
0
You can break for loops. In fact, it is used in an example in the wikipedia. VinnyTheButcher 278 — 6y
1
The for loop you made is set to act like a do end block. it only repeats once.... hiimgoodpack 2009 — 6y
0
him, it still shouldn't hang then crash my studio if it repeats once... H4X0MSYT 536 — 6y

1 answer

Log in to vote
0
Answered by
blowup999 659 Moderation Voter
6 years ago
for i = 1, i < 30 do
    --Code here
    --No longer need the if statement and break here
end
Ad

Answer this question