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

How do I make a death timer that kills you when time is up?

Asked by
LenDawson -10
4 years ago

Here is some timer script thing I found on the internet, but it has the word "teleport" in it so i'm confused:

local seconds = game.Workspace.Time local ingame = game.Workspace.InGame.Value local Game = game.Workspace.Game.Position

while true do

wait(1) seconds.Value = seconds.Value - 1

if seconds.Value == 0 and ingame == 0 then

ingame = 1 seconds.Value = 20

local teleport = game.Players:GetChildren() for i = 1, #teleport do teleport[i].Character:MoveTo(Vector3.new(Game.X, Game.Y, Game.Z))

end end

if seconds.Value == 0 and ingame == 1 then

ingame = 0 seconds.Value = 15

local teleport = game.Players:GetChildren() for i = 1, #teleport do teleport[i]:LoadCharacter()

end end

end


LocalScript in TextLabel:

while true do script.Parent.Text = game.Workspace.Time.Value wait(0.01) end

0
Community guidelines clearly state that scripts should be your own work. User#29813 0 — 4y
0
I notice you have negative rep and that your previous questions have broken the guidelines as stated in the guidelines linked above. Please read those guidelines before any more crap posting. User#29813 0 — 4y
0
Can you use a script block next time? Also did you add an IntValue and do what you need to do with it? By the way you shouldn't take scripts off the internet. H_armful 19 — 4y

1 answer

Log in to vote
1
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

What the script you found is doing is teleporting all the players in the game to a certain position in game.

For a death timer, you would need to tell the script to wait 10 seconds and kill the players that you want to kill.

If you wanted to kill all the players, it would look like the following below. If there's anything you don't understand, write a comment below and I can try to explain a bit more.

timeLeft = 10 -- how many seconds to wait before the players get killed

-- a function that kills all the players in the game. 
function killPlayers()
    local players = game.Players:GetChildren()

    --loop through all the players killing each one of them 
    for i, v in ipairs(players) do
        local character = game.Players:FindFirstChild(v.Name)
        if(character)then
            character.Humanoid.Health = 0 -- kills character
        end
    end
end

-- when this function is called, the game will start counting down the death timer
function countdown()
    --lthis is a loop that that counts down every second until i is 0
    --take note that the variable i is changing not the actual timeLeft variable
    for i = timeLeft, 0, -1 do
        wait(1)
        killPlayers()   
    end
end


--call the countdown function whenever you want the game to countdown. right now i'm calling it when the game starts.
countdown()
0
I copied the script and it doesn't work, any idea what I did wrong? ii_Rky 0 — 3y
Ad

Answer this question