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

Loop won't break, help?

Asked by
Xoqex 75
10 years ago

This is the loop:

while wait(0.2) do
    f.Size = f.Size +0.2
    if f.Size == 8 then break end

It completely ignores the break and keeps going to the max size.

Not sure how to fix, any help would be appreciated.

2 answers

Log in to vote
1
Answered by 10 years ago

I think it has to do with the decimals being involved, making f.Size a float rather than an integer. Although I don't see why that would be a problem. I'm quite honestly not sure why it occurs for you.

However, you can solve this very easily by taking use of the condition of the while-loop.

while (f.Size < 8) do
    f.Size = f.Size + 0.2
    wait(0.2)
end

You could eventually do "if f.Size >= 8 then break end" too, although I personally prefer the abovementioned.

0
Thanks, this worked, it stopped at 8.2 but I know how to fix that. Xoqex 75 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Try this

while true do
wait(.2)
 f.Size = f.Size +0.2
    if f.Size == 8 then 
break
 end
0
It didn't work, it just continued past it. Xoqex 75 — 10y

Answer this question