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

I have a while True loop that times out, any solutions?

Here's my code. Whenever i run it it gets to the print("continue"), prints the list, then it says the script timed out before resuming. Any help is welcome. :)

--Made by iiMeltex


local roundtime = 60 * 3
local finaletime = 1* 60
local intermissiontime = 15

print("Loaded 1 ")

local serverstorage = game:GetService("ServerStorage")
local replicatedstorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local maps = serverstorage:WaitForChild("Maps")
local mapholder = game.Workspace:WaitForChild("Mapholder")

print("Loaded 2 ")

local event = replicatedstorage:WaitForChild("RemoteEvent")
local statustag = replicatedstorage:WaitForChild("StatusTag")
local timertag = replicatedstorage:WaitForChild("TimerTag")

print("Loaded 3 ")

while true do	
	while true do
		wait(4)
		contestants = {}
		for _,player in pairs(game.Players:GetPlayers()) do
			if player and player.Character then
				local humanoid = player.Character:WaitForChild("Humanoid")
				if humanoid and humanoid.Health > 0 then
					table.insert(contestants, player)
				end
			end
		end	
		if #contestants >= 3 then
			print("We out")			
			break
		else	
			statustag.Value = "Waiting For More Players"
			timertag.Value = -1
			print("Continue ")
			print(contestants)
		end
	end
	print("Loaded 7 ")	
	--load a random map
	statustag.Value = "Loading A Random Map"
	timertag.Value = -1
	mapholder:ClearAllChildren()
	wait(2)
	local allmaps = maps:GetChildren()
	local newmap = allmaps[math.random(1, #allmaps)]:clone()
	newmap.Parent = game.Workspace.Mapholder
	wait(2)
	print("Loaded 8 ")

1 answer

Add a wait before the end of the first while true loop, or just delete the first while true loop completely, otherwise it is redundant to have a while true in a while true. Hope this helps!

2 comments

0

that is not the full code.. there is a wait at the end of the first while true loop and i need it because it is what keeps the game rounds going. But nonetheless thank you :)

0

oh...

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