Loading and deloading parts of my world to help optimization

I’m working on a randomly generated elevator floors system, that goes down by levels, 10 levels. Each level has a variety of 20 floors, so 200 possible floors in total. Sort of like DOORS, how each room is randomly generated.

However, selecting each floor and loading each one in at once when the player joins seems totally memory intensive and terrible for optimization. What approach should I use to loading each floor in only when requested (the player is in the elevator, moving down?) I first thought of using serverstorage and only cloning to the workspace when needed, but the issue is that still would require things to be loaded upon startup, just not rendering.

I asked around in developer communities and the general idea of looking into de-loading and loading parts within a world was suggested. I have no idea what this means, or how it works. Is there a way I can manually load and render models only when requested by a script?

It would need to be models that would be loaded, not just parts individually (that would be complete hell) as I’d be loading fully built rooms with lots of furniture and parts.

2 Likes

Instances stored in ServerStorage won’t be loaded for the clients unless they are replicated to them (e.g. cloning to Workspace), so you shouldn’t have to worry about client memory and optimization in this case. If your rooms are randomly generated, you won’t be storing “200” floors on the server. Simply store a single copy of each model that makes up a floor, and programmatically put it together (with randomness) when it needs to be loaded for the player. Optionally, include a loading screen to better hide the moment your floor is loaded in.

3 Likes

What most refer to as limitations in steaming you would think would be a plus here. Client side generation definitely would help also, considering you can create a world viewed individually from each players point of view.

1 Like

Can players be across different floors? And does all floors need to be generated immediately?

If all players are on the same floor at all times, you can just have the server clone that floor from ServerStorage into Workspace when needed, and then destroy the floor when the players leave for the next floor.

Each of the 200 floors are already prebuilt

How would I randomly select a floor and move it to the client without storing all 200 floors to choose from?

That was my original thought, but storing 200 huge models (essentially each floor is a whole game map) seems very intensive even if they are stored in Server Storage, or maybe not… I’m not sure

math.random() to get a random number between 1 and 200, then clone the floor into Workspace. When it’s no longer needed, destroy it and pick another floor. If they’re prebuilt then they need to be stored on the server, there’s no way around that.