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

How do I stop a "While true do"? Any help?

Asked by 7 years ago

Script:

1local m = game.Players.LocalPlayer.leaderstats.Experience.Value
2 
3while true do
4script.Parent:Clone().Parent = script.Parent.Parent
5wait(3)
6if m >= 5 then
7    script:Destroy()
8end
9end

The :Destroy() thing doesn't work, so how do I stop it when m is greater or equal than 5. It would be nice if you would give me the code with your answer if you have one.

3 answers

Log in to vote
1
Answered by
JellyYn 70
7 years ago

To stop a while true do, you should use break

1while true do
2    script.Parent:Clone().Parent = script.Parent.Parent
3    wait(3)
4    if m>=5 then
5        break
6    end
7end

I honestly never have tried doing this, so, I apologize greatly if it doesn't work.

0
I don't know if it works or not, in the output it keeps saying, "11:02:51.792 - startScript re-entrancy has exceeded 3" gamerbeeze1 -3 — 7y
0
https://scriptinghelpers.org/questions/28059/startscript-re-entrancy-has-exceeded-3 try reading here. Others get the same error, and is has to do with the Cloning. JellyYn 70 — 7y
Ad
Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

local SomethingIsWrong = true

1while true do
2print("Something")
3if SomethingIsWrong then
4break
5  end
6end
Log in to vote
0
Answered by 7 years ago

instead of doing "while true" do something like this..

1local running = true
2 
3while running do
4    script.Parent:Clone().Parent = script.Parent.Parent
5    wait(3)
6    if m > 5 then
7        running = false
8    end
9end

Also your problem could be that you are cloning the script and each script is cloning itself. So maybe try not to clone the scripts.

Answer this question