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)
Your Issue is simple enough to fix. When the round is ready to begin, simply check if there are 2 or more players with Playing true and NotPlaying false. If there are 2 or more players with Playing true and NotPlaying false, then let the round begin. If not, then, like you did at the beginning of the round, wait until there are enough players with AFK Mode Off.