so I am making a ragdoll system for a game I’m working on and a problem that I am encountering is when I ragdoll its nice and smooth for me but for other clients it’s not, so my client sees it as nice and smooth but the other players see me lagging, the main ragdoll script is a module script with a server script as the activator and a local script as the user input detector so it goes Local > Server > Module, below are some videos of the problem, any help is appreciated, thanks in advance.
WHAT?: Roblox networking is based on authority system.
Authority system is a part of networking, which manages ownership of every object in a hierarchy. Naturally player’s ownership is set to the client who controls the player, that’s why when you move, you basically never lag, but when you watch other players move, they sometimes lag. This can be simply tested by making a race with players from same starting point, you’ll see yourself pretty much in front of everyone, but someone else sees himself in front of you.
Objects which are not managed by any of a client and have physics applied have got variable ownership, which depends on who is closest to the object. So basically the closest player owns a part which is affected by physics. However any part, which is static is always managed by the server, if not defined otherwise (eg. ServerScript sets the ownership to player).
WHY?: And finally, the reason why it looks laggy to other players is that they don’t own your player model, and so they must wait for the server to send them the information about your state (position, velocity, …), and these informations are mostly sent using Unreliable UDP protocol, which doesn’t guarantee that all data will be received and in the correct order. This protocol is mostly used for values, which are often updated and need to be synchronized.
HOW?: The solution to this can be tricky I believe, but could be solved by managing the position and velocity of the player on client-side for every player. This means that when player jumps, the client sends RemoteEvent to the server that the player jumped, the server sends RemoteEvent to everyone else, that the player jumped and so, every client which received this message will set the velocity and animation of the player from their side. RemoteEvent is very nice in this solution, because it runs on Reliable protocol, which guarantees that the data which are sent will be received by the other end and in the correct order.
Create object of type RemoteEvent in ReplicatedStorage, and use this.
There is good Roblox documentation about the remote messages Remote Functions and Events
in the end i sorta gave up on trying to make my own system work and used this one instead which is a module made by @CompletedLoop , it is amazing and i whole heartedly recommend it:
however it is R6 only so if you need R15 then im afraid this might not work for you