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

Timer that kills people after 300 seconds?

Asked by 6 years ago

I currently have a timer that counts down from 300 seconds. Is there anyway that after the timer gets to 0, it kills all players?

Code:

while true do
 for i = 300,0,-1 do
 wait(1)
 script.Parent.Text = "Countdown: "..i 
 end
end

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
while true do
    for i = 300,0,-1 do
        wait(1)
        for _,p in pairs(game.Players:GetPlayers()) do
            p.PlayerGui.ScreenGui.TextLabel.Text = "Countdown:"..i.." seconds left"
        end
        if i == 0 then
            for _,p in pairs(game.Players:GetPlayers()) do
                p.Character.Humanoid.Health = 0
            end
        end
    end
end

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
local Seconds = 0

while true do
    for i = 300,0,-1 do
        wait(1)
        script.Parent.Text = "Countdown: "..i 
        Seconds = i

        if Seconds == 300 then 
            for _, v in pairs(game.Players:GetChildren()) do 
                v.Character:BreakJoints()
            end
        end
    end
end

Answer this question