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

I Have A Timer In My Game And It Works Fine But Whenever I Reset It Resets The Timer?

Asked by 5 years ago

As you can see it's a simple script, just using for loops to act as timers and changing the values I made when it ends. Like I said in the title the timer resets to intermission 30 seconds when I die in the game. Is there a way to make it keep counting down/be the same for everyone?

while wait() do


    --Won't start until these load
    local seconds1 = script.Parent:WaitForChild("Seconds")
    local prefix1 = script.Parent:WaitForChild("Prefix")


    --Default text and variables
    local label = script.Parent.ScreenGui.TextLabel
    local seconds = seconds1.Value
    local prefix = prefix1.Value

    --Changing variables
    seconds = 31
    prefix = "Intermission"


    --Round/Intermission loop
    for i = 1,seconds do
        wait(1)
        seconds = seconds - 1
        label.Text = prefix.." "..seconds
    end


    --Changing variables
    seconds = 11
    prefix = "Get Ready"


    --Round/Intermission loop
    for i = 1,seconds do
        wait(1)
        seconds = seconds - 1
        label.Text = prefix.." "..seconds
    end 


    --Changing variables
    seconds = 61
    prefix = "Game"


    --Round/Intermission loop
    for i = 1,seconds do
        if _G.DeadPeople >= game.Players.NumPlayers then
            seconds = ""
            prefix = "Game Over!"
            wait(4)
        elseif _G.DeadPeople < game.Players.NumPlayers then
            wait(1)
            seconds = seconds - 1
            label.Text = prefix.." "..seconds           
        end


    end


end

I tried to make the script as neat as possible for you. I appreciate any help!

0
Is this a local script or a server script? If it's a local script, then I'm pretty sure it would reset on death. spartanlord456 19 — 5y
0
It's a server script R2D2yodayolo 32 — 5y
0
Try using "repeat wait() until" and if statements so that when you die, the script will ignore everything until a certain quota is met. spartanlord456 19 — 5y
0
could i just repeat wait() until never? R2D2yodayolo 32 — 5y
View all comments (3 more)
0
Yeah, but it wouldn't do anything below that line of code, until that thing is met. spartanlord456 19 — 5y
0
If you're testing by yourself and you die wouldn't the counter stop because ``_G.DeadPeople == game.Players.NumPlayers``? Phantom1996 45 — 5y
0
It hasn't gotten to that yet. If I die during the intermission then it shouldn't do that.. R2D2yodayolo 32 — 5y

Answer this question