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 6 years ago

Script:

local m = game.Players.LocalPlayer.leaderstats.Experience.Value

while true do
script.Parent:Clone().Parent = script.Parent.Parent
wait(3)
if m >= 5 then 
    script:Destroy()
end
end

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
6 years ago

To stop a while true do, you should use break

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

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 — 6y
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 — 6y
Ad
Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

local SomethingIsWrong = true

while true do
print("Something")
if SomethingIsWrong then
break 
  end
end
Log in to vote
0
Answered by 6 years ago

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

local running = true

while running do
    script.Parent:Clone().Parent = script.Parent.Parent
    wait(3)
    if m > 5 then
        running = false
    end
end

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