At the moment, when the mentioned function is called, during a couple seconds, it will always call the same value, for a player. I was wondering if there were any ways to update this faster, as it could prove useful in lag spike scenarios.
You could use a remote function.
local startTime = os.clock()
remoteFunction:InvokeServer()
local delay = os.clock() - startTime()
2 Likes
Is it possible to make this secure, though?
You could have the server invoke the client instead, make sure to use pcall
to avoid errors. If you invoke from the server then exploiters can’t manipulate the ping to be lower than it actually is.
Don’t use InvokeClient. The client can manipulate this to make the server hang forever or manipulate the data as they please.
Yes, the pcall
comment addresses one of the issues, but not close to all of them. I personally would use literally anything else than :InvokeClient()
.