I’m working on making a timer system for my players in game. However, I’m trying to find the best way to remove lag from the server and individual clients so the game can run smoother.
What I want to achieve is the clock ticking down one second at a time until 0, and then something will happen. I want to event to occur for everyone, so I want to make sure it is timed with absolute precision.
There are three ways I could go about this:
Run the clock on the server so it updates for all players at the same time.
Run the clock on individual clients and continually fire RemoteEvents.
Run the clock on the server, lag individual clients behind if the timer is behind and then pair it up at the end (bad idea but it could work)
Which route should I take? If not these three, which other way should I do this?
Yeah just run it on the server. Depending on how the client is performing it could be slow or fast - who knows! Lag is typically negligible in these cases.
Running it on the server will mean that it is pretty much the same for everyone in game, whereas running it on the client may cause inconsistency and it may be different for different players. If you wish for it to to update for everyone at the same time, you’re probably better off running on the server as oppose to on the client. Continually firing remote events will likely cause more lag than just running it on the server.
Thanks. This is also random, but since I’m controlling this using a ServerScript, if I wanted to put the timer into a GUI, would I have to get the player using a RemoteEvent? Sorry to bug you if you’re busy.
If you are looking to change something about a GUI, but you’re running it from a SeverScript, there are a few ways to do this. The easiest way, in my opinion, is to change the value of a StringValue (placed in ReplicatedStorage/ServerStorage) via the ServerScript, then use :GetPropertyChangedSignal(“Value”) in a LocalScript (inside the GUI) to update the GUI. You can check out the links I provided to read more about how you might go about this.