Help! How to save a timer on reset

Basically, I’ve made a timer work. Right? and so it works fine it goes from 5 minutes and then to 0 and then when the next wave comes it restarts the timer. The Waves are unniversal and save each time the plr resets. However the timer doesnt. It restarts at 5 minutes. Which is quite annoying and im really confused, im trying to make it save however nothing i have tried has worked.

This is the server script

OnTimer.OnServerEvent:connect(function(plr, timerLabel)
   
   if wave.Value ~= 6  then
    local seconds = 0
    local minutes = 5
    while true do
         

         
      
            seconds = seconds - 1
            if seconds == -1 then
                minutes = minutes - 1
                seconds = 59
            end
            
            
            if minutes == 0 and seconds == 0 then
                    timerLabel.Text = minutes..":00"
                break
                
            end
            
            
            
            
                
            
            
            
                if seconds < 10 then
                timerLabel.Text = minutes..":0"..seconds
                
            else
                timerLabel.Text = minutes..":"..seconds
                
            
                
                min.Value = minutes
                sec.Value = seconds
                
                
                
                
                
            
                
                
            
        end
        wait(1)

        
    
           end
    end
    
    if timerLabel.Text == "0:00" then
        NextWave:FireAllClients()
    end
    
end)

This is the client script

if plrcount.Value >= 1 and started.Value == false then
        started.Value = true
        
        
        
        
        OnTimer:FireServer(timerLabel)
        start:FireServer(timer.Waiting)
        
    elseif plrcount.Value < 1 then
        waiting:FireServer(timer.Waiting)
        
    end

started is a bool value
plrcount is an Number value which increases when a plr enters and decreases when the player leaves.

Any help is appreciated. Thank you

4 Likes

Track it on the server. Have a numbervalue in Workspace, and have the server script change it.

On the client, just read that numbervalue and display it accordingly.

You could also use a stringvalue, instead of two numbervalues, with the value of the minutes and seconds formatted already.

4 Likes

Thank you so much, this helped out a lot!

It works really well, but the problem is if there is more than 1 player in the game it flickers between different times. My assumtion is everyone has a different time. How do i make it so there is only one time? @Xiousa

1 Like

Don’t have the client fire the server. No need for events. Just have the server start the timer.

Have the server constantly check for 2 or more players, then start the timer from there.