Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

how do I make a round system where after everyone dies the round ends ? I wanna get the core concept

Asked by 3 years ago

I know these kinds of topics are already there but As I have said I am really new to scripting and don't really understand many lines of code which results in understanding nothing and thus I will be dearly grateful if someone makes me understand the concept I don't want someone to spoon-feed me the code but instead guide me by the line so that I can understand by myself and script it

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

this is incomplete and won't work but something like this could help

local Players = game:GetService("Players")

local playersInRound = {} -- empty table for now

-- when the round starts
playersInRound = Players:GetPlayers() -- put every player in the table

for i, player in pairs(Players:GetPlayers()) do
    player.Character.Humanoid.Died:Connect(function(player) -- make this run every time someone dies
    if table.find(playersInRound, player) then -- if they are still in the round, remove them from the table
        table.remove(playersInRound, table.find(playersInRound, player))
    if #playersInRound == 0 then -- when there is nobody in the round, the table will be empty so last index will be 0
        -- do code to end the round 
        end
    end)
end

Ad

Answer this question