Lag Compensation for Latency dependant combat game

Hello, I would like to know if there is somehow something that can compensate for latency in Roblox.
For a long, long time I’ve been trying to find solutions to this problem, how to replicate some of the movements from the client to the server, and then make it smoother. But for a long time, even though I optimized my game to the maximum, nothing would work anyway.

As a very classic example being the dash mechanics, when you do it on the Client side, when you execute it, for yourself it will become very fluid, the way you want, however for the other players, it will become very fluid. weird, because there would be that problem where the movements are replicated to the server and it ends up that the player (who performs the dash action) would be “teleporting” to the end of the dash trajectory, and this is very bad for combat games, especially when it comes to combos in the air, where you have to take the opponent into the air and then do combos, it ends up that when we want to put in certainly customized physics, like a falling effect ( a more fluid and dynamic gravity based on calculations you make) on the ground by the server (if the server is managing this) will mean that the opponent will never fall, a solution may in fact be to have to send a signal to this same client (enemy), but send several signals all the time it doesn’t look so cool and from time to time it can even cause several bugs, when it comes to checking the server and the client, well, the server, even though it does a lot of calculations, it’s not a big problem when your game doesn’t have that pile of loops.

However, it is very frustrating not being able to do something because of a tiny thing, which affects the entire gameplay. My fighting game tends to depend a lot on how replication is done, and I’m still unsure whether I should use Unreliable Remote Events for these types of actions that include more dynamic physics on the client side, although I should or can also do it on the client side. Server side (for NPCs), it doesn’t seem very interesting to give ownership of the Network to the player, an exploiter could mess everything up.

By the way, in my entire game, I use a single Remote Event only, and on both sides of the game, there are their main loops, which I use as a kind of “Queue”, which simply manages a good part of what I want. I thought it would make it optimized, but I’m still unsure if that’s a good thing, because I use a table, and inside the loop (RunService on the intended side) I use the “for do” application to execute the functions, in my head, I thought ( and I think, I’m still unsure if it’s a good idea for me to continue with this) that it would be more optimized instead of putting in several loops and the server having to manage each one of them individually.

My game’s mostly based on “Devil May Cry 5”, and its mechanics too, such as aerial moves (that you will be “stuck” in the air), and it’s one of the main reason that i’m trying to find an solution for so long.

So, friends. I would like to know if there is a solution to the problem I am currently having. If so, contact me here. Thank you very much.

3 Likes

I happen to encounter a very similar situation. I’m making a vehicular combat game where lag compensation is vital, for precise server-authoritative hitboxes, with lag compensation. Here is my experience with it.


Unfortunately, roblox doesn’t give you almost any control over their network replication. You can’t change the 20Hz frequency and huge buffer. Issues such as these are almost unfixable in default roblox:

  • Weird and inaccurate player movement (such as the dash example)
  • Huge latency between clients
  • Bad client-to-client physical collision physics
  • Unsecure hitboxes due to lag

I’d wait until they raise the limit from the 900 bytes(pls roblox dont ignore our cries for help if you’re reading this) but it shouldn’t matter too much. Unreliables are best when you only care about the newest update from the server.


Fortunately, there is a solution to this. However it will require VERY heavy rewriting and lots of time to do:

Custom Replication: The key into a secure & optimized netcode

Ditch the default roblox replication. It causes a lot of problems, desync & lag. Competitive games such as yours will benefit a lot from it.

This isn’t an easy task at all. However, except for the ability of lag compensation it brings other immense benefits:

  • MUCH more control over network flow: Roblox no longer decides if your game should have lagspikes or not. It can be even better than StreamingEnabled network-wise.
  • You know exactly what data is being sent, and when: This is important for secure lag compensation.

A Roblox-specific approach would be like:

  • Parent all your important server instances in the server’s camera: they don’t automatically replicate.
  • Use an ID system to store entities & their info about them (characters, NPCs, etc) and replicate them.
  • A networking library like ByteNet is absolutely essential for such a large-scale networking task. Default remotes are very heavy, and bytenet significantly optimizes them.
  • Disable CharacterAutoLoads and replace it with your own system. Assign player.Character locally, and store it elsewhere in the server (if you assign it in the server, it will replicate which is bad)

Here are a few amazing articles regarding network replication: They cover pretty much everything you need to know. They also helped me a lot:

2 Likes