Confused on client-server communication

I’ve heard that it isn’t recommended to tween on the server, and to always tween on the client. So this brought up the question, why are some things done on the client but are visual server-wide (like animations), but some things are done on the client and aren’t visual server-wide? I don’t know which things are safe to do on the client and which aren’t. For example, I want to tween an arm’s size during a punching animation. I did it on a server script and it worked fine, but someone told me that I shouldn’t tween on the server. If I played the tween on the client, would it even be visible to others?

Some things are automatically replicated to the server. This includes things like animations playing on a client and the position of a character’s limbs.

Size is not a replicated property (in terms of client → server) and so you will need to tell all clients to tween the arm.

For Example:
UpdateArm:FireAllClients(someArm, newSize)

However I suggest only firing everyone except who requested to have their arm’s size changed, and then to do their own arm size change on their own client so they don’t see the latency between their remote call to the server and the server’s call back.

--// Client

sizeMyArm(newSize)
UpdateArm:FireServer(newSize)
--// Server
for i, player in pairs(players:GetPlayers()) do
    if (player ~= personWhoWantsArmSizeChange) then
        UpdateArm:FireClient(player, personArm, newSize)
    end
end
6 Likes