How to make matches?

I want to know how to make a matches, like if every player dies, game ends, start new one. But I am not sure how to make it. So I need some help putting it to together so that it works. I am also pretty new to making matches.

1 Like

You can either put Players in a Team, or store them in a Table, you can then check if they died and remove them from the List, then you can check if the number of Players on the Team or the Number of Items in a Player is less than 1 to determine if all Players died, Here is an Example

local PlayersPlaying = {} -- To Store our Players for a Match

-- Adding Players
for _,player in game.Players:GetPlayers() do -- Iterates through all Players
    table.insert(PlayersPlaying, player) -- Adds Player
    player.Character.Humanoid.Died:Connect(function() -- Died Event
        table.remove(PlayersPlaying, PlayersPlaying[player]) -- removes Player
    end)
end

-- Checking Players
if #PlayersPlaying < 1 then -- if the Number of items is less than 1 (0)
    print"All Players have Died!"
    -- break the loop? fire something that signals the end?
end


3 Likes

Try searching on the DevForum for anything’s that is related to a round system, it’ll help you

1 Like

I wasn’t able to find anything that fits my issue, I checked Youtube and the DevForum.

I want to make the round system work like this.

new round → wait until every player dies → restart cycle.

I don’t want a game timer, I want it to wait until every player dies. Like Plates of Fate.

Like this?

local playersInGame = {}
local intTime = 5
for intTime = 5, 0, -1 do
    print(intTime)
    task.wait(1)
end
local function startRound()
    for _,player in pairs(game:GetService("Players"):GetPlayers()) do
        local character = player.Character or player.CharacterAdded:Wait()
        table.insert(playersInGame,player.Name)
        local gamePoint = workspace:WaitForChild("GamePoint").CFrame
        character:WaitForChild("HumanoidRootPart").CFrame = gamePoint
        local humanoid = character:WaitForChild("Humanoid")
        humanoid.Died:Connect(function()
             if table.find(player.Name) then
                 playersInGame[player.Name] = nil
                 end
             end
        end)
     for _,name in pairs(playersInGame) do
        if name == nil then
            return "Ended"
        end
    end
end
if intTime <= 0 then
    local status = startRound()
    if status == "Ended" then
          print(status)
    end
end

idk this script isnt really that good

Have you tried looki by for ‘round system’ in both #help-and-feedback:scripting-support and #resources:community-tutorials? I’ve seen a lot of them in the last few days…
Maybe you just searched the worng thing :sweat_smile: