Stopwatch Handling

Hey all! Today, I created a stopwatch function that times the player’s speedun time throughout each obby. That means each player will have their own stopwatch while their running through the course.

Right now, I have the stopwatch being controlled on the server such that a number value within replicated storage is changing as the stopwatch changes in a heartbeat connection, and the GUI on the client’s side uses a .Changed event on the value to update the local UI. Once the player reaches the finish, the connection is disconnected. I decided to control the stopwatch on the server to prevent any exploits from the client.

I wanted to know if there was a better way or more efficient way of handling this. My ping went up to around 300 and I’m becoming sort of suspicious that it’s due to the stopwatch running on the server, but I may be wrong. Thank you for all the help!

1 Like

You could try to tell the client when the stopwatch starts and count on the server and the client separately (maybe …)

I was thinking of doing something like that, but I can’t figure out any way to have the timer run on the client and have a sanity check on the server without an exploit happening.

You could count on the server, but let the client know when the stopwatch started, and let the client count separately. you can send a RemoteEvent with an argument of the unix time that the stopwatch started to the client, and let the client count from that unix time, and update the client every x seconds

1 Like

You don’t need to count on the server if you just need the time it takes for their speedrun. The server should just store the start time and then at the end, find the difference between the start time and end time and have that as the official number.

Though on the client, you should have a timer that actively shows the player how much time has passed. There COULD be some variance between that timer and the final end time that the server will calculate. I think this difference of server and client timer would increase over time so if necessary, you may want to periodically update the client timer so it doesn’t drift too much.

1 Like

@charliemin2009 @Badandy11 these are perfect answers, thank you so much for your time :slight_smile: