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

How to make a positive Server-Client relationship?

Asked by 6 years ago
Edited 6 years ago

I'm at a dilemma where I want to maximize the player's experience while reducing server load.

I'm not sure what I should be giving the client to handle either as if the client get's too much load won't that increase it's latency between the client and server?

I'm also wondering what the server should be handling, and if it should even be handling things such as animations of npc's as walking, jumping, etc seems to put a heavy load onto a server when having lots of npcs.

As for remote events, will creating too many and setting up connections between them lag? or only if I'm firing it too many times a second

0
I had watched the performance presentation on yesterday's RDC 2018 livestream. I recall that having multiple remote events is more efficient than using one event. xPolarium 1388 — 6y
0
Thats not what he said. He said that multiple remote events would be more efficient as you commonly send extra data than with just one remote event. But there is no difference. User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hi Faded,


What Side To Use

I recommend just using whatever side is most convenient for the script you're trying to implement. If you're going to be using CurrentCamera or RenderStepped, then obviously you're going to need to make use of Client-Side. However, if you're going to use .PlayerAdded or scripts that you will need the server to utilize such as, billboard gui management or sound management or particle management, then you would need to use Server-Side.



Should The Server Handle NPC Animations?

Well, yes it should handle NPC Animations because all animations because replicating all the animations for each client would increase a lot of latency and also possibly cause a lot of errors because your client will want the NPC to do certain things while others' clients would tell the NPC to do other things.

However, if you want to animate your own Character, you should play them from the client since that makes the most sense and is the most organized. Also, all animations played by the client get replicated to the server, so there's no loss there.



Will Connecting RemoteEvents Cause Lag?

No, just connecting them won't cause lag. It's the block of code that you run that will cause the lag. So, you need to make sure your block of code is very efficient so it can decrease the amount of lag you cause. Don't fire RemoteEvents too much in a short amount of time though, because running huge blocks of code at once can cause lag. You need to allow the server time to process the call.



Lag

Lag is caused by inefficient code, so make sure you use the most efficient methods possible. Remember, DRY: Don't Repeat Yourself. So, you should hesitate repeating two blocks of code.

Whatever code you think you may be using over and over, just return it in a module script or make it a RemoteFunction/RemoteEvent so that you can easily access it and call it every time you need it. Great examples of this would be sound managers and particles managers and part creation.

If you're using FE and want to create parts from the client, you're going to need to create them from the server if you want the rest of the server to be able to see them. The same goes for Sounds and Particles. So, I would recommend making RemoteEvents to manage them and just call those RemoteEvents each time you need to make them. This will help you manage your code.

Lag can also be caused by running blocks of code too fast and just having blocks of code running in the background when you don't need it. So, make sure to minimize infinite loops or just loops that run for long amounts of time in general. Only pull up code that you need and let the rest be stored.



What To Use To Reduce Lag

I recommend using StreamingEnabled because it can reduce lag. So, if you're really worried about lag, then definitely use StreamingEnabled. Also, I know this may sound strange but also use FilteringEnabled. It can indirectly reduce lag as it keeps your methods more organized and makes you use efficient ways, such as using RemoteEvents and RemoteFunctions to handle data and server changes.


Hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

Ad

Answer this question