Hello to all. I’ve been having some (input?) lag in my game that I can’t properly identify and I was wondering if it was due to high client pings or my usage of remote functions.
The problem is a sort of input delay between how quickly we can use effects, which works perfectly fine in studio.
To first describe the lag, I thought it was on the server because I previously had all my tools firing to a single remote function in Replicated Storage, that a single server script handled in ServerScriptService. After giving all tools their own remote functions and scripts, it somewhat helped but there is still delay.
However, sometimes I or other people can play without any delay, and then other times it comes back. We’ve noticed that our own pings are higher during those times, as well.
How exactly can I control this? I’ve played other combative games which doesn’t have any client-lag and delay at all.
These resources seem useful but, how does it fix that there’s lag in some cases and in others its virtually fine? Sometimes we’re plagued with high pings, other times we aren’t. The Cannon article seemed useful but, does it really answer this?
-All of my key inputs wait for the server to finish showing us the effects in the server script.
-The micro profiler didn’t seem to spike that much
-I don’t use many while loops other than for two functions using Run.Stepped:Wait(0.01), although they’re used pretty frequently
One player suggested its due to our internet service load, but is this really the case? In the other game I mentioned above, this “input delay” or the client lag has never happened
If you are using a remote event to trigger your effects then there is going to be lag because your forcing the client to communicate what effect it wants to the server then the server has to trigger the effect and then tell all the other clients that the effect is happening so that everyone can see it. This takes a long time which is why you are seeing a delay. The reason why you dont see that lag in studio is because when your testing in studio, the server and client and essentially the same machine so it takes hardly any time at all to communicate between them
To fix this you just need to make the client handle the special effects on their own from a localscript.
I see. I was thinking the same thing.
Sometimes in-game, we’re able to receive the lowest amount of delay, just shy away from how it is in studio. So, essentially, it works exactly as it should, and then other times how you would expect the client-server transfer update ( the lag we see)
And if I had the special effects on a local script for every effect, wouldn’t I need local scripts for every player so they can see them? Or at least a function that distributes it to every player
It changes depending on the person because of their ping. I said earlier that for your effects to trigger currently, you have to communicate at least twice with the server. this already takes a long time, if you have a high ping it will take even longer.
I suggest you have a localscript inside each player that controls their own special effects. So for example if I fired a cannon and wanted to have an explosion effect appear at the end of the barrel. The localscript in my player would cause the effect to happen instantly for me so I wouldn’t experience any latency.
At this point I would then use a remote event to tell the server to tell all the other clients to simulate the same effect. All the other clients would experience latency but its not nearly as important because they aren’t controlling that cannon and are probably focused on their own instead. The most important thing is to remove the latency for the person using the cannon to give them the best experience.
I see.
I do have to say the input response for the player is just as important as the effects showing up for others because this is for a fighting game. With all due respect I appreciate your solution, but I feel it’s possible to accomplish the same thing with less amount of work. One person elsewhere, for example, had given a example by fixing up a tiny part of my code