Exhaustion allowed execution time

Hello!

I made a Round Script. It works well, but at the end of the round, studio would freeze and timeout the script. I tried many things, different posts, but they didn’t work, and I have wait() in the script. Help is appreciated!

repeat
		timer -= 1
		Status.Value = "Round starting in "..timer
		wait(1)
	until timer == 0
	local PartToDelete

	for count = 1, #Map:GetChildren() do 
		timer = tonumber(#Map:GetChildren())
		timer -= 1
		Status.Value = "Round Time left: "..timer
		local ChildrenOfModel = Map:GetChildren()
		PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)]

		if PartToDelete.Name == "LandPart" then 
			PartToDelete.Material = Enum.Material.Neon
			PartToDelete.BrickColor = BrickColor.new("Really red")
			wait(time_between_destroy)
			PartToDelete:Destroy()
		else
			repeat 
				PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)] 
				if PartToDelete.Name == "LandPart" then 
					PartToDelete.Material = Enum.Material.Neon
					PartToDelete.BrickColor = BrickColor.new("Really red")
					wait(time_between_destroy)
					PartToDelete:Destroy()
				end
			until PartToDelete.Name == "LandPart"
			end
	end
	for i, v in pairs(plrstable) do
		print(v)
	end
end

Try add the wait before you add the code.

repeat
               		wait(1)
		timer -= 1
		Status.Value = "Round starting in "..timer
	until timer == 0

But there is a wait in that repeat line?

The script is also a While true loop, and that line is just part of the code that’s inside the loop.

I don’t know about this but try breaking the for loop?

Didn’t work, it timed out again.

That’d break my entire game. I need the while loop

settings().Studio.ScriptTimeoutLength = -1 -- Will stop exhaustion in scripts.

How to handle “Script timeout: exhausted allowed execution time” - Help and Feedback / Scripting Support - DevForum | Roblox

My studio is freezing forever. My studio crashed too.

I do not even know, try checking the link to the post I put in.

I did. But the posts following the solution were unrelated.

It’s maybe because you don’t have a wait() statement in your for loop.

1 Like

I don’t think that it is a maybe, im pretty sure that there’s no wait() in the script

nvm I found a wait in the script so isnt that

Try adding a wait() statement in your for i,v in pairs loop and your for count loop.

There are waits in the scripts.

maybe do repeat wait() would fix it

I found where the error is:

repeat
		wait(1)
		timer -= 1
		Status.Value = "Round starting in "..timer
	until timer == 0
	local PartToDelete

	for count = 1, #Map:GetChildren() do 
		timer = tonumber(#Map:GetChildren())
		timer -= 1
		Status.Value = "Round Time left: "..timer
		local ChildrenOfModel = Map:GetChildren()
		PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)]

		if PartToDelete.Name == "LandPart" then 
			PartToDelete.Material = Enum.Material.Neon
			PartToDelete.BrickColor = BrickColor.new("Really red")
			wait(time_between_destroy)
			PartToDelete:Destroy()
		else
			repeat 
				PartToDelete = ChildrenOfModel[math.random(#ChildrenOfModel)] 
				if PartToDelete.Name == "LandPart" then 
					PartToDelete.Material = Enum.Material.Neon
					PartToDelete.BrickColor = BrickColor.new("Really red")
					wait(time_between_destroy)
					PartToDelete:Destroy()
				end
			until PartToDelete.Name == "LandPart" --Where the error is

In the repeat loop your only using a wait if the partname is landpart, so if you dont have landpart in the table itll just break the repeat until loop.

So where do I add a wait() in the repeat?