I have a question regarding the .Touched function. When creating two scripts, one LocalScript and one Script, with the following code:
local ClockStart = nil
local Debounce = false
if game:GetService("RunService"):IsServer() then
ClockStart = workspace:GetServerTimeNow()
workspace:SetAttribute("ClockStart", ClockStart)
else
ClockStart = workspace:GetAttribute("ClockStart")
end
workspace:WaitForChild("Brick").Touched:Connect(function()
local TouchTime = workspace:GetServerTimeNow() - ClockStart
if not Debounce then
Debounce = true
print(TouchTime)
--> Client: 12.842
--> Server: 11.985
task.wait(1)
Debounce = false
end
end)
When printing from both scripts, there is often a small difference. I assume it’s just regular client-server latency; however, as you can see above, sometimes the server returns a lower time than what the client returns.
Does anyone know why this happens? And what would be a better alternative to accurately and precisely determine the touch time as shown above?