Updating CFrame to other clients?

(EDIT) My last inquiry was vague, I’ll rephrase:

I am using a RenderStep function to change the C0 of the characters Root Motor6D every frame. Every frame, I get the hit normal of a ray to orient the character in an upright position depending on where they are standing. As you’d expect, it looks fine locally but does not replicate to the server or other clients.

I’ve tried sending server signals via remoteEvent every frame but I assume this is inefficient. I’ve seen games perform this well but I’m not exactly sure how.

It reads like you’re doing all of it on the clients end. If you want replicated CFrames have you considered perhaps keeping the CFrames on the server end and having all the clients utilize this to move said part? Also due to the fact it’s being ran entirely on the client it could also be exploited, so updating CFrame for everybody else could be risky.

That said, I don’t know what your use case is, nor what you’re doing. Could you try to elaborate more?

Have all clients perform the update on their end and forget replication. That being said, an obscure use case and lack of context make it hard to determine the requirements for resolving your problem. What exactly are you trying to do?

1 Like

Perhaps I should send a signal to the other clients to tell them to render it on their own? If so, what’s the best way to do that?

You should probably additionally do this on the server since it is not controlled by the client. The Heartbeat event may be what you’re looking for. It runs immediately after physics (and before replication). By using Heartbeat you can change the C0 property and have it replicate to all clients and physics will replicate along with it.

Alternatively you can have all clients perform this raycast and position for each player’s character on their own clients. This will function exactly the same as above but there are some tradeoffs:

  • Doing this client side results in less network usage
  • Doing this server side results in less CPU usage
  • Doing this server side means scripts see what clients see
2 Likes

That makes more sense.

I would like to do this using the heartbeat method, do l still send data from the client each frame?

Based on your description of the issue it sounds like this can be done entirely server sided. Generally you don’t want to allow the client to change joint CFrames since it can lead to some crazy exploits (which existed on Roblox a while back I think). This would also double your network usage and take up remote bandwidth. (Remotes have a soft 50kbps limit. Going over this will linearly increase perceived ping but measured ping will not show this making the game appear incredibly laggy for seemingly no reason)

Here’s some examples of what can go wrong:

  • The player can make themselves semi-invisible by placing their body joints very high and deleting it client side
  • The player can easily cause touch events for anything they want by repositioning their body to a target and jumping
  • The player can launch/fling other characters by repositioning their body partially intersecting another player
  • A lot more

Ok, I’ve made it so code operates on server, but this causes the localPlayer’s movement to be less smooth. How can I make the player see their own movement smoothly?

For the localplayer you’d want to keep doing what you were doing before on the client. Generally for local movement you want to copy your code for both because it’ll make sure latency isn’t an issue.