How to detect how long a client is taking to respond to a remotefunction?

You can write your topic however you want, but you need to answer these questions:

  1. I am trying to make an anticheat which uses partial client and server side

Before you lecture me about not trusting the client, I am very aware. There is only a client side for redundancy and keeping script kiddies out. Most of the anticheat relies on the server side, and all information sent between the client and the server is encrypted.

  1. I cannot find any resources to learn how to detect how long the client is taking to respond to the remotefunction request.

  2. I have looked on the developer hub.

Thanks for your help!
-Luxxe

1 Like

Since RemoteFunctions yield when you invoke them, you could just store the value of tick() in a variable and then when you hear back from the RemoteFunction subtract from it to see how long it took.

local function getResponseTime()
local timeElapsed = tick()

someRemoteFunction:InvokeServer()

return tick() - timeElapsed
end
3 Likes

They could yield for an infinite amount of time theoretically.
Perhaps it would be better if he were able to check the time since the invoke started regardless of whether the client has responded yet.

local function invoke_with_response_time(remote_function, on_finished)
 local start = os.time()
 local finished = nil

 task.spawn(function()
   local data = remote_function:InvokeClient()
   finished = os.time()
   on_finished(data)
 end)
 
 return function get_time()
   return not finished and os.time() - start or finished - start
 end
end

3 Likes

Welp no help. Needed Bow!!! So Yeah!!!

What are you trying to say? This is very confusing.

1 Like

Don’t worriY about it. TBH idk what I was saying…