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

How Do I Make My Script Start A New Game Once All Players Are Dead?

Asked by 6 years ago
01local s = script.Stat
02local vals = game.ReplicatedStorage.vals
03t = 0
04while true do
05    t = 15
06    repeat
07        t = t-1
08        s.Value = "Intermission.. "..t
09        wait(1)
10    until t == 0
11    s.Value = "Game starting!"
12    wait(2)
13    local mapselect = game.ReplicatedStorage.Games:GetChildren()
14    local choose = math.random(1,#mapselect)
15    curnum = 0
View all 53 lines...
0
why are you posting your main script without an attempt? GoldAngelInDisguise 297 — 6y
0
the idea is to get those playing using a table, when a player dies they will be taken out of the table, once the table is empty, restart GoldAngelInDisguise 297 — 6y
0
whats wrong? starmaq 1290 — 6y
0
okay thank you i have tried but nothing works Odlnsonthor 11 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

You would have to make a table and then remove them once they have died. Example:

01for x, player in pairs(plrs) do
02        if player then
03 
04            character = player.Character
05 
06            if not character then
07            -- left the game
08            table.remove(plrs,x)
09        else
10            if character:FindFirstChild("GameTag") then
11                -- They are still alive
12                print(player.Name.." is still in the game!")
13            else
14                -- They are dead
15                table.remove(plrs,x)
View all 23 lines...

Then You would want to restart so when the player left in the table is <= 1 then you would do (Example):

01if #plrs == 1 then
02    -- last person standing
03    Status.Value = "The Winner is "..plrs[1].Name
04        break
05elseif #plrs == 0 then
06    Status.Value = "Nobody won!"
07    break
08elseif i == 0 then -- This is the time of the match is up (If you have a certain time)
09    Status.Value = "Time's up!"
10    break
11end
0
Thank You Very Much Odlnsonthor 11 — 6y
Ad

Answer this question