local Start = game.ReplicatedStorage:WaitForChild("Ingame")
if Start.Value == false then
local Player = 0
for i,v in pairs(game.Players:GetChildren()) do
Player = i
end
if Player > 1 then
print("Yes")
game.ReplicatedStorage.Game:Fire()
Start.Value = true
end
end
end
Script timeout: exhausted allowed execution time
BindableEvent script:
game.ReplicatedStorage.Game.Event:Connect(function()
print(“Yes”)
local Point1 = workspace.Spawnpoint1
local Point2 = workspace.Spawnpoint2
local Team = game:GetService("Teams")
local RedTeam = Team.RedTeam
local BlueTeam = Team.BlueTeam
local Starting = true
local team = 0
for i,v in pairs(game.Players:GetChildren()) do
if team == 0 then
print(v)
v.Team = RedTeam
team = 1
else
print(v)
v.Team = BlueTeam
team = 0
end
end
repeat
local RedTeam2 = 0
local BlueTeam2 = 0
for i,v in pairs(game.Players:GetChildren()) do
if v.Team == RedTeam then
RedTeam2 = RedTeam2 + 1
elseif v.Team == BlueTeam then
BlueTeam2 = BlueTeam2 + 1
end
end
if RedTeam2 == 0 then
game.ReplicatedStorage.End:Fire("Blue")
Starting = false
print("end")
end
if BlueTeam2 == 0 then
game.ReplicatedStorage.End:Fire("Red")
Starting = false
print("end")
end
until Starting == false
end)
game.ReplicatedStorage.End.Event:Connect(function()
print(“End”)
local Ingame = game.ReplicatedStorage.Ingame
local Teams = game:GetChildren("Teams")
local WaitingTeam = Teams.WaitingTeam
for _,v in pairs(game.Players:GetChildren()) do
v.Team = WaitingTeam
end
wait(10)
Ingame.Value = true
What’s the code in the BindableEvent? It’s probably an issue there. That or may need to set the Value of Start to true before you fire the BindableEvent
More specifically, what does the code handling the event do? If the called code doesn’t yield, then the scheduler will wait until that code is finished before resuming here.
It’s highly likely that you are doing too many expensive operations without any yielding in that event handler.
local RunService = game:GetService('RunService')
-- run service will never break, unless your performance broke
RunService.Heartbeat:Connect(function()
local Start = game.ReplicatedStorage:WaitForChild("Ingame")
if Start.Value == false then
local Player = 0
for i,v in pairs(game.Players:GetChildren()) do
Player = i
end
if Player > 1 then
print("Yes")
game.ReplicatedStorage.Game:Fire()
Start.Value = true
end
end
end)