How do I drastically improve networking for my game?

As you can see the overall isn’t really that good :sweat_smile:


What I want:

I want each player to be able to expand their plot so they’ll probably have around 150-200 turrets in the end. I also want a lot of balloons and bigger balloons can pop into smaller ones (around 1,000 per plot maybe). Each server should hold atleast 4 players.

What I’m doing right now for Balloons:

When I want to spawn a balloon, I create a Configuration and set its attributes: StartPosition, Health, Name, and ID for client identification. The client simulates the balloon movement so they only need the initial position. The client listens to the folder that is the parent of these configurations and either creates or deletes a balloon object.

What I’m doing right now for Turrets:

Right now only turrets are visible on the server. For the turrets, I’m doing the same thing as the balloons for creation or deletion. On the server, it uses a hash grid to get all the balloons that is in range and uses a simple distance check to find the closest one. Then it sets the TargetID attribute on the turret model to the closest balloons ID; the client can then lerp the cannon muzzle to face the balloon. Theres also a Fire attribute that changes every time the turret shoots; when changed, the client will play a muzzle flash FX. (The cannon shown in the picture shoots every 0.1 seconds and has a range of 10)

Obviously what I’m doing isn’t cutting it. What can I do to improve my networking? I ideally want it to be 30-40 kb for some headspace to do other stuff.

Using attributes is a very bad way to talk with the client

You should use remote events first and look into buffers and compression

1 Like

Hm yeah I see. I went with this method because it was the easiest to implement.

This is true for the most part, but attributes are often used to replicate state, not to signal. Lowering this down to “communication with the client” would be naive. This makes it hard to replace them entirely, as attributes are guaranteed to reach the other end, while Remotes are best-effort. So if the OP uses attributes to replicate state, replacing them entirely would be a headache to say the least.

Aside from that, as @happya_x mentioned, what you need is a buffered & compressed networking library; for this, I highly recommend ByteNet. It is optimized out of the box, and idiomizes a “only use what you need” policy.

If anyone needs an update here it is. Averaging from 100KB to just around 15KB with 4 plots full of balloons and towers simulating. :smiling_face_with_sunglasses: (I used Packet - Networking library)



This might be too complex but, I would recommend switching visuals to being client rendered. You said the turrets were on the server. Why not just have clients render them instead? From what I can tell this seems to be a tower defense type genre game. I would recommend Suphi Kaner’s video Tower Defense - Roblox Scripting Tutorial

This video will give you all the information you need and more.

The turret being rendered on the server doesn’t cause any issues since all the turret FX are only rendered on the client. The reason I have the turret’s models on the server is so players can see other players turrets; balloons, FX, etc are all on the client. I can put the models on the client only but its really not worth the extra complexity for a tad bit of performance gain. Turret models on the server aren’t being used by anything since all the data for turrets aren’t stored in their models but rather in code which is better for performance anyways.