Basically, I've been making a PVP game with rounds. I made an AFK button, everything works fine, but if there are only 2 players and one of them is AFK, the game still starts but the AFK player doesn't join, so the other player automatically wins. Help would be appreciated
(There are 2 values that are inside the player, either "NotPlaying" or "Playing")
Here is the script:
-- Define Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local MapsFolder = ServerStorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLength = 120
local Reward = 35
-- Game Loop
while true do
Status.Value = "Waiting for enough players"
repeat wait(1) until game.Players.NumPlayers >= 2
Status.Value = "Intermission"
wait(20)
local AvailableMaps = MapsFolder:GetChildren()
local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace
Status.Value = "Picking a map..."
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player:FindFirstChild("Playing") and player then
table.insert(plrs,player)
end
end
wait(2)
(This is only the part of the script where it adds the players)

1 comment
Can’t you simply check the amount of non afk players and if it is less than 2, then the game wont start