Physics Engine on Server and Client are not in sync

I am not sure how this is possible, and it is likely an engine bug. I set the CFrame of the HumanoidRootPart when the player joins the game on the client. Then, I set the CFrame of the HumanoidRootPart on the server when the game starts. As you can see, most players did get teleported, but one got bounced back. It appears that she did get teleported on the server, and it replicated, but it did not replicate for her client. This means the client and server are out of sync.

5 Likes

For reference, all my workspace properties are at default behavior and the code used for teleporting on client was: HumanoidRootPart.CFrame = Target

Then server I tried using model:PivotTo and HumanoidRootPart.CFrame. I got the same results shown in the video.

This is how I calculate the CFrame on the server

local offsetX, offsetY, offsetZ = math.random(1,4), math.random(3,10), math.random(1,4)
local teleport = Selected_Map.TeleportPart.CFrame * CFrame.new(offsetX, offsetY, offsetZ)
HRP.CFrame = teleport

I think the issue is that their network connection froze before they got teleported. The reason they appear to “bounce” back is because server moved their character for everyone else to see, and when their network un-froze their character position is just where they were before the freeze. This is because the packet telling them they were teleported got lost due to the freeze, their position on their side gets replicated, which “snaps” them back to the spawn area on everyone else’s screen (on their screen it probably didn’t look like they got teleported at all).

I think a workaround on your side is to use a RemoteEvent to tell clients what position they should teleport to, because those packets never get dropped and so they will always end up teleporting.

I experienced this behavior myself, and it only happens every now and then. On the client’s screen, it appears that they don’t get teleported at all when it occurs. The other people not bouncing back to the spawn area, appear to have fully synchronized with the server and client on their character physics.

I implemented the Remote/Client workaround yesterday and that appeared to keep the character on server and client in sync.

Additionally, I tried forcibly resetting the network ownership of the HumanoidRootPart by following the steps below, but it appeared to have no effect on the problem:

HRP:SetNetworkOwner(nil)
local offsetX, offsetY, offsetZ = math.random(1,4), math.random(3,10), math.random(1,4)
local teleport = Selected_Map.TeleportPart.CFrame * CFrame.new(offsetX, offsetY, offsetZ)
HRP.CFrame = teleport
HRP:SetNetworkOwner(Player)

Hey! So sorry for the late response, I just sent this over to the engineers.