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

How to kill the player once the timer reaches a certain limit?

Asked by 3 years ago
Edited 3 years ago

Hey there! I'm trying to figure out how to make the player have health on 0 (therefore, killing the player) once a timer reaches by, lets say, 10 minutes. I couldn't figure this out.

if mins >= 10 and seconds >= 0 then hum.Health = 0

This however doesn't work. Usually my time is around 0 to start. but the script sets the time to 10:00, Immediately killing the player once they spawn.

local mins = 9
local seconds = 40

repeat
    if seconds >= 10 then
        mins = mins + 1
        seconds = 0
    else
        seconds = seconds + 1
    end
    if seconds < 10 then
        script.Parent.Text = tostring(mins)..":0"..tostring(seconds)
    else
        script.Parent.Text = tostring(mins)..":"..tostring(seconds)
    end
    wait(1)
until mins >= 10 and seconds >= 0
if mins >= 10 and seconds >= 0 then
    local chr = game.Players.LocalPlayer.Character
    local hum = chr.Humanoid
    hum.Health = 0
end
0
Add a code block, and indent your code. DinozCreates 1070 — 3y

1 answer

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

"if mins is greater than or = 10 and if seconds is greater than or equal to 0" it's greater than. so it's killing the player. Script is just doing what you tell it to do.

Here's operators.

https://developer.roblox.com/en-us/articles/Operators

">= Greater than or equal to
<= Less than or equal to"

0
No, that is not what I meant. I need the time to start the value of the mins and secs back in lines 1 and 2. but instead of the time starting at 9:40 (the value of the first two variables), it starts at 10:00 (this is what I need help with. Whatever value I put in the first variables it will always start at 10:00.), repeatedly killing the player every time they spawn. OriginalPacificalSun 0 — 3y
Ad

Answer this question