I didn’t even see that, don’t know why those are your calculated values but I have one idea. For the ping if you are trying to compare os.clock values they are not the same on server and client which is probably why you are getting those crazy values.
EDIT: This is why people try to make time sync modules, but it can be avoided.
os.clock measures how long the CPU has been running. The servers in Roblox run for a long time, hence the huge numbers. Using remotes/remote functions would be your go-to solution.
os.clock ( )
Returns the amount of CPU time used by Lua in seconds. This value has high precision, about 1 microsecond, and is intended for use in benchmarking.
You’re probably sending the clock time from the server to the client, and not calculating it from client only.
With RemoteEvents:
--// Client
local Remote = -- The remote event
local startTime = os.clock()
Remote:FireServer()
Remote.OnClientEvent:Wait() -- Waiting for server response
local ping = os.clock() - startTime
--// Server
local Remote = -- The remote event
Remote.OnServerEvent:Connect(function(Player)
Remote:FireClient(Player)
end)
With RemoteFuntions
--// Client
local RemoteFunc = -- The remote event
local startTime = os.clock()
RemoteFunc :InvokeServer() -- Waiting for server response
local ping = os.clock() - startTime
--// Server
local RemoteFunc = -- The remote function event
RemoteFunc.OnServerInvoke = function()
return
end)
This is only the RoundTrip part, RoundTrip is fine.
I send the server os.clock() back, and since it doesn’t measure game runtime, but hardware time from the actual servers of roblox, it gives huge values. Hence you writing:
EDIT: Also this is round trip ping only:
And i need Client-Server and vice versa. But thank you all, i can work around this since, i know now what causes this.
I’ve seen people use methods like this and just half the value of round trip, this might not be completely accurate but just an idea if you don’t want just round trip.
Also apparently Roblox is adding in a built in way to get the ping of the Player which is probably way more accurate than our hacky methods, but it hasn’t been released yet. Player | Roblox Creator Documentation
happened to me in my game that i used os.clock() on, so i made a number value in replicated storage and it changes from a server script and instead of using os.clock() i used that value and it worked fine