Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why is handling some stuff in the client better?

Asked by
starmaq 1290 Moderation Voter
5 years ago
Edited by DeceptiveCaster 5 years ago

I always get an advice saying that handling some stuff (like rays and tweens) in the client side is better. It's lag friendly and has faster responsivity for some reason. I think that is for having these tasks happen locally for each player, without having to change them in the server for all players, which should prevent server lag. But I am surely totally wrong. I don't really understand why, can anyone explain?

2 answers

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

I'm glad you asked about this! I have several times told new scripters to do things on the client instead of the server, pretty much for performance.

The reason you want to do this is because if you do a bunch of unnecessary stuff on the server (say, "rendering" (animating, lerping, cframe etc.)), you basically give the server more to do. Think about this: there are 20 players in a game, each player communicates with the server several times per second, the server also replicates each client's position, it also replicates animations, buildings, handles other stuff like gun shots, input validation and so on. This is the kind of stuff the server is meant for. Does this sound like a lot? Probably , and that is why you don't want to do things that are actually supposed to run on the client, on the server!

The server (in this case) is only one computer and it has to deal with 20 players at the same time. Also, think about the replication lag. First, the server renders a part to this position on its own, then, it has to replicate all of the information to the clients, which also have to do exactly the same thing. The clients don't have the same connection stability and speed, and there might be network lag. For the player, this will look terribly stupid and ugly, and definitely not smooth.

. I like to ask myself; "is it really necessary for the server to do this, can't the client do it? Why should it be on the server, and not on the client?". Weigh out both alternatives, the more and better arguments you can find for one alternative, the more likely it is that you should go with that. Ask questions about why you do something, and you should be able to find out whether you should do it on the server or not.

If I were to figure out if I should do this on the server or the client: "Move a part from point A to point B", I would have asked: "Why should it be on the client, what are the advantages?"

  • It's smooth for the player

  • It doesn't affect the other players, so I don't need to involve the server to validate etc.

  • It's not crucial for the gameplay, it's just for the visual impression

Also, as incapaxx said, the disadvantage of having it on the client instead of the server is the difference between what's where, due to the delay. But if you had done this on the server, it would have been the same, due to the network delay.

0
Thank you a lot for this rich answer, I always know the general idea and all, but I never manage to dig too deep starmaq 1290 — 5y
Ad
Log in to vote
1
Answered by 5 years ago

Would have closed for being a discussion but this is interesting and since i'm so nice i'll give you a pass, tho try avoiding subjective, discussion like questions. Your question should be answered, not discussed. If you'd like a discussion start one in the forums.

Because it can be better.

Such movement should be processed on the person playing the game and not only the server. You do this for that immediate feedback. So it feels smoother for them. The disadvantage I can think of right now is it may not be in sync with other players and/or the server, mainly due to the performance of their device and other factors. On one client the part could be at position (50, 72, 81) but on another it may be on (53, 79, 90), the server might have it at (52, 73, 84).

0
Thank you so so much :> starmaq 1290 — 5y

Answer this question