Secure and Extremely Precise Timing Method

I am working on a game with the core mechanic based around timing players on various courses and displaying the times on various leaderboards. It is competitive in nature, and as such I have been working on a timer that hits both of these categories as much as possible.

My first (and current approach) is completely server-sided. I have a timer manager script that uses .touched() and os.clock() to count the times of players. At first I thought this was foolproof given the fact that it meant the client could not spoof their times and sent a low time to the server.

What I realized after implementing this in game, though, is that there is some cases such as when users have high ping where they are given unfairly low times due to the fact that the server doesnt register them as having started until after they have already started.

This is an issue as I need these timers to be extremely accurate given the competitive nature of this game. I know I could switch to a local approach which would mean some of these issues would be nonexistent. The issue is that an exploiter could easily spoof times, resulting in an even more ufair experience.

This is where you can come in. I am not an incredibly experienced Lua/Roblox scripter so I am not sure what the best approach is here. I know some sort of combination between server and local scripts with sanity checks would probably be optimal, but I am not sure what the best configuration for this would be. I’d be extremely grateful if you could provide some ideas or help brainstorm solutions with me. Thanks for your time!

-Ethan

I suggest getting rid off the Touched events, not reliable, and client can play with Touching events.

I suggest let client ask to start the course. Server verifies if player can start or not, then position player on starting point of track and start timer.

Its possible to constantly track the player position server sided to determine when a player crossed the finish line, meaning players with high ping could get worst times, but in theory the delay caused by high ping should not have a “significant impact” on the outcome.

Additionally, you can set up a system that detects and compensates for latency.

Those are just personal ideas Im not saying thats the best approach.

1 Like