How do I make a global timer instead of local ones

Basically, what i want to do is make only one timer, so if another plr joins whilst a round is happening it will still have the same time for him and the other player. I want the timer to be able to carry on at the same time if the players reset or die.
I’ve done this so far, and it carries on the same time when the player resets however when another player joins it flickers between the times.

Here 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
			
			
			
		    
			    
			
			
			
				
			
				
				min.Value = minutes
				sec.Value = seconds
				
				
				
				
				
			
				
				
			
		
		wait(1)

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

Here 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

------------------

local function Value(value)
	if value < 10 then
				timerLabel.Text = min.Value..":0"..value
				
			else
				timerLabel.Text = min.Value..":"..value
	end
end

Help is always appreciated

3 Likes

Maybe make a Timer value in workspace with a script in it; when it is changed send a remoteevent to all clients with the new number

2 Likes

If you’re doing it for something like waves, you might wanna invoke server to get current server status.
This should be done on player added. Server should tell client when round ends/starts as well.
Otherwise, you can just have a value somewhere accessible by both client and server. Server would update the value and client would log the .Changed and act according to it.

2 Likes

A really simple way to do this would be to put a NumberValue in ReplicatedStorage and have the server update it every 1 second (or whatever interval you want), and then using NumberValue.Changed update the GUI text locally every time the value is changed.

4 Likes

I would do this or just fire a remote event telling each client the time on the server every second. I wouldn’t recommend invoking the server for something like this.

2 Likes