How to make Motor6D.C0 replicate on all clients?

Hello,
I’m trying to make a smooth animation for each rig using Motor6D but it doesn’t replicate to all the other clients, I am using Runservice to update the character to lerp to the mouse cursor to make it run smoothly. Is there a solution to this that doesn’t necessarily tax the server too much?

Here is how the animations look to give a better idea;
https://streamable.com/izppv

Thank you in advance!

3 Likes

You could give network ownership of all of the parts, set the Motor6D and then set the CFrame of the part to it’s existing CFrame.

-- client
RightShoulder.CFrame = ...
RightArm.CFrame = RightArm.CFrame
player.CharacterAdded:Connect(function(character) -- obv in a playeradded event
   for _, part in pairs(character:GetChildren()) do
       if part:IsA("BasePart") then part:SetNetworkOwner(player) end
    end
end)
3 Likes

You can replicate it with RemoteEvents. You can’t send it every frame or after every physics update, because that would cause bandwidth. What you want to do is fire the RemoteEvent from the client to the server every time the client’s mouse moves, with an optional cooldown around 0.1 between each invoke, although I think you should put one there.

Once the server receives the data from the client, you’ll have to make all of the clients interpolate that one player’s joint’s C0, which means that you have to interpolate Player1’s joint’s C0 on Player2’s and Player3’s clients: we don’t want to do it on the server because the server will have to send changes to the client, so we want to do it directly

You should also try to send the least possible data to the server as there’s a limit to how much data can be sent over the Client-server model before bandwidth occurs, which is 50KB/s. You shouldn’t send the entire cframe, rather send a number or vector to calculate it on all the other clients.

9 Likes

Worth noting but the client is implicitly given network ownership of its own character. To be precise about it: the HumanoidRootPart is network owned by the client and because it is the root of the character assembly, other parts in the character also inherit said network ownership.

Network ownership only replicates physics changes, not property changes. Updating the CFrame of a joint will not replicate even if network ownership is given to a client.

6 Likes

What would be a better solution then over sending data to the server for it to update all the clients?

I thought if you update the CFrame of the part it would replicate? That’s why I updated the CFrame after changing the C0.

@Solar_Wraith Since Roblox doesn’t quite offer replication control to developers, pretty much the only luck you’re going to have in a situation like this is to periodically send some data over. Don’t update CFrames from the server though; have the server only act as a medium for transferring data. Each client should, on its own, update the way another character is facing using data it gets from the server.

@Uralic No, as CFrame updates are not tied to the physics pipeline. Updating a CFrame will only occur on the client who is setting it; no other client will receive this change. A remote must be involved for any kind of CFrame replication.

3 Likes

Alright, thank you for the help!