Is there an event or any way to set up code to run when physics is replicated to clients? I am looking for a result that works locally.
According to this thread
I think this code should do it, although it’s not aligned with the physics replication frame rate (~ 20Hz ~= 60Hz).
local connectPhysicsReplication do local runService = game:GetService("RunService") function connectPhysicsReplication(part, callback) local last = 0 runService.Heartbeat:Connect(function() local t = part.ReceiveAge if t ~= last then last = t callback(t) end end) end end
ReceiveAge doesn’t seem to fire roblox signals, using
GetPropertyChangedSignal seems of no use.
Also is it a bad idea to be pinging to server and clients back and forth? I need to send ping data to client to make people be ahead of where they are on server for accurate collisions.
You may look into clock syncing algorithms
Quenty has made one available in a module here:
Once you get the offset, you can then send timestamps with the events and find out how much it was delayed, so you can then use that to extrapolate other players’s positions.
What I currently do is generate ping tables when server gets client pings back and sets their ping to the time since it was fired to them. I send this ping table to clients when pinging to them so they can locally predict movement offsets and make cars closer or further ahead.
Why do you need to do this?
Bc roblox physics latency compensation stinks really bad so you hit people you didnt actually hit and people appear like they are in different places. You can hit them if you attack the players projected location; doing this locally so the client has a much easier job predicting where they are to attack and win and etc. Without this, derby modes are ruined and races are unfairly won.