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

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

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

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.

2 comments

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"

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.

local SomethingIsWrong = true

while true do
print("Something")
if SomethingIsWrong then
break 
  end
end

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.

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