idk how to explain but i have a function but idk why it still can’t get the function. i think the function startGameTimer() trying to get the startIntermission() but the startIntermission() doesnt exist yet since i place the startGameTimer() on top. Even if i switch the place between these ofc it will be the same. so the point here i want to make after the startGameTimer() end, it will automatically turn to startIntermission(). (like a loop never stop cycle)
local function startGameTimer()
gameActive = true
for i = gameTime, 0, -1 do
timer:FireAllClients("GAME TIME LEFT: " .. i .. " seconds")
if i % 5 == 0 then
local zombies = 0
local survivors = 0
for _, player in pairs(pl:GetPlayers()) do
if player.Team == game.Teams.Zombie then
zombies = zombies + 1
elseif player.Team == game.Teams.Survivor then
survivors = survivors + 1
end
end
if zombies == 0 then
timer:FireAllClients("Survivors Win!")
task.wait(3)
gameActive = false
break
elseif survivors == 0 then
timer:FireAllClients("Zombies Win!")
task.wait(3)
gameActive = false
break
end
end
task.wait(1)
end
if gameActive then
timer:FireAllClients("Time's up! It's a Draw!")
task.wait(3)
end
for _, player in pairs(pl:GetPlayers()) do
player.Team = teamw
local rootPart = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
if rootPart and game.Workspace:FindFirstChild("Part") then
rootPart.CFrame = game.Workspace.Part.CFrame * CFrame.new(0, 1, 0)
end
end
startIntermission()
end
local function startIntermission()
while true do
if #pl:GetPlayers() > 1 then
for i = timertime, 0, -1 do
timer:FireAllClients("INTERMISSION: " .. i .. " seconds left")
if audiop then audiop:Play() end
task.wait(1)
end
timer:FireAllClients("PREPARE FOR BATTLE!")
task.wait(1)
teleportPlayers()
task.wait(3)
startGameTimer()
break
else
timer:FireAllClients("Waiting for more players...")
task.wait(3)
end
end
end
task.spawn(function()
startIntermission()
end)