Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do I handle FilteringEnabled Lag?

Asked by 7 years ago
Edited 7 years ago

My current project contains melee combat, which means there is a lot of things happening on the client side, and server side. This is my first game using FilterEnabled, and I wasn't sure what the best method of dealing with lag would be; so I simply made the scripts in charge of swords and sword combat server side. This works great, except for the input lag. When someone clicks to swing their sword, the server script loads the animation (swinging sword) into the humanoid and checks for Touches while it's swinging. Depending on the number of players, there is a noticeable space of time between clicking and the animation loading.

My first thought was to load the animation with a LocalScript because animations replicate. This made input response immediate, but since it moved the delay to you seeing the animation instantly vs other clients seeing it later. Being struck with swords no longer looked accurate on everyone else's screen. The biggest obstacle is that I'm using directional combat, which means you choose a direction to swing, and your opponent sees this animation start and has to block in that direction before the sword hits them.

I'm not sure where I go from here. People don't like input lag, and people don't like being hit by a sword that they were out of range of on their screen. Anyone have any ideas on how to deal with this?

2 answers

Log in to vote
3
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
7 years ago

Ideally, there would be no latency and no problem doing everything on the server, but you can see for yourself the problems with that.

ROBLOX is really bad for network latency - and there's nothing you can directly do to fix it.

One method you have available to make it less obvious is to have both the Client and Server render the animation. I don't recall the exact timings to have the Client animation override the Server, but if you use both and have the Server handle the collision, you get an immediate animation on the Client, and the best-possible collision detection on the Server.

0
Thanks for the idea, I will look into it and let you know how it goes. Toadboyblue 67 — 7y
Ad
Log in to vote
3
Answered by 7 years ago
Edited 7 years ago

Use the right script

LocalScripts and ServerScripts should not be used interchangeably. They have very different physical real-life properties that you need to consider when using them. Local scripts run directly on the client, meaning the player's computer is executing the source code inside the script in their local copy of the game. Server scripts execute their code on the server-side end of the network, which is hosting the game. Two completely different machines, with completely different purposes.

Why?

Given the brief summary of how both scripts differ, you should have a better understanding of how to use them for the right job. ROBLOX shouldn't be registering a user's input, the user's computer should. Anything that's specific to a single user, or that should be processed locally, should be done in a local script.

Latency

There's no direct solution to reducing network latency in general that you have any control over. I've actually answered something similar to this before, which you can find here. Your only option is to make efficient use with the tools you have. Personally, I suggest you learn about all of these topics in detail before progressing any further in this subject:

If you have any questions about how these relate to your problem, or about the category itself, just let me know. For now, my conclusion would be to handle all of your input locally, and use remotes to update the server about these changes.

0
Thank you for your time; I fully understand both subjects, and I provided the pros and cons about doing it as you said. I've decided the pros outweigh the cons, and I'm now working on a way of handling what should be handled locally to reduce input lag.. even though it could potentially cause problems. Toadboyblue 67 — 7y

Answer this question