Issues with optimization! Please help


Hey! I’m running into an issue with my fishing game.

In the game, players can place eggs that hatch into fish. Each fish is a physical model that gets saved to their plot, and there’s a limit of 100 fish per plot. The problem is: when there are a lot of players, the game starts lagging a lot — probably because of the huge number of fish models. Strangely, it doesn’t lag as much on mobile.

To fix this, I was thinking of only showing the fish on the client side, while keeping all the data stored on the server. My idea was:

  • On the server: store a version of the fish model, but without any visuals — basically just the data.
  • On the client: use that data to spawn the actual animated fish with bones and movement.
  • That way, each player would see their own fish and other players’ fish, but they’d only be loaded and animated locally, to save performance.

I’ve tried a few different ways to make this work, but I keep running into problems:

  1. When I tried rebuilding everything locally and only saving part of the data to the server, players would lose their progress if they left or the game shut down before the data fully loaded.
  2. I also tried using both server and client models, with a CFrameValue inside to track positioning. That sort of worked, but it was super inconsistent — like, if I tabbed out while the game was loading, the fish would show up fine. But if I stayed focused in the game, they wouldn’t appear at all.

So yeah, what I need is:

  • A setup where fish are only displayed locally, but the data is still saved and managed on the server.
  • Something reliable that keeps data safe even if the game closes or the player leaves while it’s loading.
  • A way to show both your own fish and other players’ fish — all locally, to keep the game running smoothly.

Would really appreciate some help or suggestions on how to pull this off.

Here’s how it’s organized in scripts, if it helps:

  1. EggPlacement_Server → In ServerScriptService

This script is the core of my whole fishing/farming system, handling:

Placement

Growth

Rare traits

Persistence (saving/loading)

Limits and rules

Visual/audio effects
  1. PlotAssignment_Server → In ServerScriptService

This script handles the plot (farm) system in my fishing game, doing:

Assigns free farm to player

Sets up the sign in front of the plot to showcase the players user and character image

Teleports player to their farm

Keeps track of which farms are taken and free

When the player leaves:

Saves fish and egg datas + Clears the farm for next player who joins

  1. EggPlacement_Client → In StarterPlayerScripts

This LocalScript mostly just handles visual stuff, like highlights, the hovering model of the egg when you move your mouse and else. Don’t think it needs much of a description.

This is pretty much it.

Change all fish meshes properties as such:

CollisionFidelity should be set to Box

RenderFidelity should be set to Performance

This should mitigate the issues you are having. It doesn’t seem like you have enough meshes to generate that much lag unless you have the settings set otherwise

I might suggest using the profilers to determine the source of the lag.

So no need for me to move it on the client? Well, I’ll test this in a bit and let you know.

No, you shouldn’t have to. The CollisionFidelity will contibute to server lag, while the RenderFidelity will contribute to client lag. Changing just the RenderFidelity should increase your framerate

I’ve used thousands of mesh parts before with little lag using the proper settings for performance

Well, I’ve turned to box all the collisions however it still does indeed lag.

Look at the difference.

Here’s an example of how a fish model looks:

Does disabling the animations help with the framerate?

Not really. Perhaps maybe it’s the fact that they constantly move?

But no, because I made it so that if you get far away enough they stop moving, and it doesn’t reduce the lag.

Maybe it’s the fact that every single one of these fishes has bones.

But actually no, because I do remember that I tried testing with just the Handle part (deleting everything inside) and it’d still lag.

Maybe there is something that constantly loops in one of my scripts and that lags the game?

Now this is kinda weird, because if I put the fish models in workspace like this, they won’t lag

I might have a theory… there’s a bunch of
while true do
in my scripts,
I’m gonna try to get rid of some of those and then I’ll try.

Use the ScriptProfiler to see what is consuming the most resources. You see it by opening the F9 menu and switching to the ScriptProfiler tab

Rate doesn’t mean much, it’s more the activity % on the right that matters. We can’t observe much happening in the F9 menu, I suggest you open the real microprofiler instead so we can have a better chance. (Settings → Microprofiler → Detailed mode)

I actually solved it, thanks. It was indeed the heartbeat running every second lol.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.