How to make a server-wide timer

I am making a tag-like game, and I want a server wide timer to count down the time for the rounds and intermissions. I want to handle this on the server side, but I’m not quite sure how. I’m using remote events, but if I fire one every time the amount of seconds changes, it might cause lag. If I activate it every time the timer restarts, then players joining in the middle of a round won’t see a timer until it restarts. How could I make the timer without either of these issues?

1 Like

Fire it when a player joins and when the value of the timer INCREASES let the client decrease it (aswell as the server but without firing) so both of them has the same value, when it gets to 0 and now will start counting down from another number fire a remote with the new number and repeat

1 Like

Sorry, I don’t really understand. Could you explain it in more detail?

Instead of using a remote event, you should have a Int (or string) value in replicated storage call it Clock, have a local script in your countdown ui:

local RS = game:GetService("ReplicatedStorage")
local Clock = RS.Clock

Clock.Changed:Connect(function(newVal)
    script.Parent.Text = newVal
end)

Then in your server script all you have to do is update the clock value and it will automatically update every players UI

4 Likes