So I have this module script with a bunch of loop scripts But I ADDED A BUNCH OF WAITS…
Instead Roblox Studio crashes like this:
1: I am not able to move in studio for a few seconds
2: Studio goes white
3: after some time it does come back with this:
Sounds like you could be missing a wait somewhere.
Could you post some code so we could peer through it and figure out the problem?
--
local Spawns = workspace:WaitForChild("ZombieSpawns")
local Enemy = game.ServerStorage:WaitForChild("Enemy")
local Zombies = workspace:WaitForChild("Zombies")
--
module.Round1 = function()
wait()
local Folder = Spawns:WaitForChild("Round1")
local func = coroutine.create(function()
for _, spwn in pairs(Folder:GetChildren()) do
wait(2)
if spwn:IsA('BasePart') then
wait()
local copy = Enemy.Invader:Clone()
copy.Parent = Zombies
copy.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0,3,0))
end
end
end)
print("Round 1!")
coroutine.resume(func)
end
module.Round2 = function()
local ran = math.random(4.25,8.5)
wait()
local Folder = Spawns:WaitForChild("Round2")
local func = coroutine.create(function()
for _, spwn in pairs(Folder:GetChildren()) do
wait(2)
if spwn:IsA('BasePart') then
wait(5)
local copy = Enemy.Invader:Clone()
local copy2 = Enemy.Charger:Clone()
wait(ran)
copy2.Parent = Zombies
copy.Parent = Zombies
copy2.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0,3,0))
copy.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0,3,0))
end
end
end)
print("Round 2!")
coroutine.resume(func)
end
module.Round3 = function()
local ran = math.random(3,7)-- random wait time
wait(2)
local Folder = Spawns:WaitForChild("Round2")
local func = coroutine.create(function()
wait(2)
for _, spwn in pairs(Folder:GetChildren()) do
wait(2)
if spwn:IsA('BasePart') then
local copy = Enemy.Invader:Clone()
local copy2 = Enemy.Charger:Clone()
wait(ran)
copy2.Parent = Zombies
copy.Parent = Zombies
copy2.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0,3,0))
copy.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0,3,0))
end
end
end)
print("Round 3!")
coroutine.resume(func)
end
return module
It seems to be crashing on line 36
Maybe try to change wait() to task.wait()
i don’t think that would fix anything
OP try commenting out the coroutine.resume’s and play and see if thats whats causing the exhaustion
Your for loops have wait times which they will not at all cause exhaustion so that is my best guess based on code.
What’s on/around line 36? I can’t find anything off with the code you gave.
could we see the script that’s calling the module function?
all I am getting even commenting out the resume things is line 36
I don’t see how any of this would be entering a tight infinite loop.
You say it happens at line 36, with the pairs(Folder:GetChildren()). If the Folder had a billion things in it and no wait() in the loop at all, it’d definitely freeze for a long while, but that’s not it.
The coroutine stuff ensures that the code calling the round functions will continue unaffected by all the wait()s inside the coroutine. I’d blame this if the wait()s at lines 10, 32 and 58 weren’t there.
The culprit has to be something else, even if the timeout error might’ve pointed to this script. (?)
Try disabling whatever script uses this module.
If it still freezes, it’s definitely something completely unrelated.
If it doesn’t, then try pasting some of the zombies manually, maybe they’re the ones with the infinite loops.
Your right I checked the zombies’ scripts or mobs it’s the one causing this, and I don’t understand why it would say it on the module instead of the mobs’ scripts
You only require a wait if its a while loop. For loops usually don’t require a wait. I’m guessing your problem is that your waiting far to much. You might want to look into using some events to fire functions when something happens, like when something is added into the game or removed.
Try publish it and test in roblox game, if work its a roblox studio or pc problem, if no, its a code or engine problem

