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

The game restarts after one player dies. Why is this happening?

Asked by 4 years ago

I am creating a round script for my game and I am stuck. I want to know how all players will return to the lobby after they are killed, but the round only restarts after one player is killed, and the time also freezes for other players that are still alive in the game/round. Why is this happening? I just want to get to the point of the script.

while true do
    wait(1)
    ftime = ftime - 1
    text.Value = "Time: ".. ftime
    Playing = workspace.Players:GetChildren()

if #Playing == 0 then
    for _, v in pairs(workspace.MapFolder:GetChildren()) do
        v:Destroy()
    end
    break
end

if ftime == 0 then      
    for _, v in pairs(workspace.MapFolder:GetChildren()) do
        v:Destroy()
    end
end

for _, v in pairs(game.Players:GetChildren()) do
    if v.Character.Humanoid.Health == 0 then
        workspace.Players[v.Name]:Destroy()
        end
    end
end
0
In line 11 you are breaking the while loop. User#24403 69 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

In the line between 23 and 24, you'll need to add a break. If you don't add it, the loop will stop working after one player reset and returns to the lobby. It's funny how I've answered my own question.

Ad

Answer this question