I’m struggling to understand why I’m getting exhausted allowed execution time on a certain part of my code; all of the loops wait() and when I click on the error, it directs me to the wait(10) line of the following script:
function Round()
local RoundCount = tostring(PlayerCount.Value)
local Events = true
for _,house in pairs(workspace:FindFirstChild("Houses"):GetChildren()) do
if house:FindFirstChild("HouseOwner") then
local plr = game.Players:FindFirstChild(house.HouseOwner.Value)
local char = plr.Character
local hum = char:FindFirstChild("Humanoid")
if plr and hum then
hum.Died:Connect(function()
house.HouseOwner:Destroy()
plr.Team = SpectatorsTeam
end)
end
end
end
while EnoughPlayers do
TextEvent:FireAllClients("Game Started")
wait(1)
TextEvent:FireAllClients("")
wait(5)
while Events do
if EnoughPlayers then
local randomevent = coroutine.create(function() -- creates a sub-event to allow code to run simultaneously
events.RandomEvent()
end)
coroutine.resume(randomevent)
wait(10)
else
Events = false
break
end
end
wait()
break
end
if not EnoughPlayers then
RespawnPlayers()
Waiting()
end
end
edit: It has only started happening since I added the death event, and it happens on respawn