Right now I have it so when there are more than 2 players out of afk the intermission will start.
repeat
for i, plr in pairs(game.Players:GetPlayers()) do
if plr:FindFirstChild("AFK").Value == false then
table.insert(AvailiablePlayers,plr)
end
end
Status.Value = "Waiting for Players ("..#AvailiablePlayers.."/2)"
wait()
until #AvailiablePlayers >= 2
Round.Intermission(10)
function module.Intermission(Length)
for i = Length,0,-1 do
Status.Value = "Next Round Starts In "..i.." Seconds"
wait(1)
end
end
But When the player becomes afk during intermission and the game starts it still puts them into the game. I am trying to get it so it will start waiting for players again if a player goes afk and there are less than 2 players to play.
I have tried making it so the code runs twice before and after the intermission but it still does not work as intended.
If anyone knows what I can do to get this to work correctly or needs anymore explanations let me know
Note: This whole script is in a while wait do loop to redo everything once the game is over
local Round = require(script.RoundModule)
local Status = game.ReplicatedStorage:WaitForChild("Status")
while wait() do
repeat
local AvailiablePlayers = {}
for i, plr in pairs(game.Players:GetPlayers()) do
if plr:FindFirstChild("AFK").Value == false then
table.insert(AvailiablePlayers,plr)
end
end
Status.Value = "Waiting for Players ("..#AvailiablePlayers.."/2)"
wait()
until #AvailiablePlayers >= 2
Round.Intermission(10)
local ChosenMap = Round.SelectMap()
local ClonedMap = ChosenMap:Clone()
ClonedMap.Name = "GameMap"
ClonedMap.Parent = game.Workspace
local contestants = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("AFK").Value == false then
table.insert(contestants, v)
end
end
local ChosenSeeker = Round.ChooseSeeker(contestants)
for i, v in pairs(contestants) do
if v == ChosenSeeker then
table.remove(contestants,i)
end
end
wait(2)
Round.TeleportSeeker(ChosenSeeker)
if ClonedMap:FindFirstChild("Spawns") then
Round.TeleportPlayers(contestants, ClonedMap.Spawns:GetChildren())
else
warn("ERROR: Forgot To Place/Name Map Spawns")
end
Round.InsertTag(contestants, "Contestants")
Round.InsertTag({ChosenSeeker}, "Seeker")
Round.StartRound(60,ChosenSeeker,ClonedMap)
contestants = {}
for i, v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("AFK").Value == false then
table.insert(contestants, v)
end
end
if game.Workspace.Lobby:FindFirstChild("Spawns") then
Round.TeleportPlayers(contestants, game.Workspace.Lobby.Spawns:GetChildren())
end
ClonedMap:Destroy()
Round.RemoveTags()
wait(2)
end