Would "return" be affected by latency?

Ok so, lets say we use :InvokeClient() on the server;

Server:

local Hi = Test:InvokeClient(Player)
print(Hi)

Then, on the client, we do this

Test.OnClientInvoke = function()
   task.wait(3)
   return "b"
end

The server would print “b” after 3 seconds.

However, I have a question.
If the client had a latency of 1000ms, so it took 1 second for the client to get the invoke, would the “return” also have a 1000ms delay?
I want to know this since I’m trying to make responsive hitboxes, but I don’t want it to be exploitable.

I believe the latency is amount of time it takes to travel to Device and go back to Server. So with 1000ms latency, it should take 0.5 seconds from the server to client. Then 0.5 seconds from the client to server after return “b”.

1 Like

For Remote Functions, it depends on the latency of the Client then the server will receive the response and send it back, if the server is laggy it will take longer and same for client.

If it returns and the user has a latency of 3000ms, it will take 3 seconds for the server to get the response.

1 Like

I want to point out something unrelated to your question, but about using remote events in a server -> client -> server fashion


RemoteFunction

It is especially important to consider that clients cannot be trusted, and could willingly (using exploits) prevent your remote function from ever returning, creating waiting threads on the server that are never removed (until the player leaves?). This is why it is advised to not use :InvokeClient()

1 Like

The delay for your remote function invocations is the round trip time, which is server to client ping plus client to server ping. The two latency values are often not the same, so a 100 ms delay does not necessarily imply 50 ms client to server ping and 50 ms server to client ping.

I don’t suggest using remote functions for hitboxes, especially if you want to invoke the client from the server. A lot of games now let the client handle the hitboxes and fire a remote event with their results, which the server verifies.

1 Like