Detect if map was replicated to client

Overview

  • I have a map stored in ServerStorage.
  • I use the roblox clone() function to copy from ServerStorage to Workspace
  • After map is cloned and parented I move the players to spawns.

Problem

  • On the players screen the map’s parts are still popping in after server clones the map to Workspace. I don’t want players still seeing map parts loading in. How can I monitor whether the parts have actually replicated to the client successfully?

Notes

  • I have multiple large maps so replicated storage would not viable if players need to store all of those parts.
  • I tried looking on the forum and google, but so I haven’t found this problem. What should I be searching for to find the solution if there is one?
2 Likes

You may want to look into the “RequestQueueSize” property of the “ContentProvider” service.

When the server streams a mesh, union or another asset to a client, the request queue will reflect that, therefore comparing the request queue against “0” should let you know when the client has loaded everything and has the ability to render it.

Do note that similarly upon initial load, your frames may drop for a moment when streaming large maps all at once, which can place sudden stress on the render clock, slowing things down for a moment. You can also attempt to send smaller chunks at a time to alleviate this problem, or move the camera away temporarily to limit the render stress for each frame.

Edit:
I would also recommend you upload/save your maps as an asset, and use the “InsertService”’ function: “LoadAsset” to load them dynamically when needed. This will same you a TON of memory, as you’re not only not storing more than one map on the server at a time, you’re also not duplicating any.
https://developer.roblox.com/en-us/api-reference/class/InsertService

Good luck!

3 Likes

I don’t think this is a problem whatsoever. InsertService does nothing to mediate the problem, its actually worse, because it takes time to load in assets.
If its stored on the server, memory won’t be a problem.
@ash877, maybe divert the players camera from the map? It would stop the players from seeing the parts load in. Alternatively, you could put the maps in Replicatedstorage.

I would imagine the server has a finite amount of memory allocated to it just as similarly as with the client has a 4 GB cap by it being 32 bit?

Given, if the maps are simple enough, and don’t take up much memory, then not much of a problem. I would say presuming they’re always going to be simple isn’t a good rule to operate under.

The server as far as I know doesn’t. Take games like Phantom Forces, it has a ton of maps (I think maybe 40 or 50 counting the VIP server ones?), yet doesn’t have any issues with memory.
Their maps aren’t simple either.

It’s think its a bit to difficult to speculate either-or, I’m not certain how roblox does its server instancing but It wouldn’t make sense if they did not have some sort of allocation limit, otherwise, anyone could just exploit such behavior and cost ROBLOX a fortune in cloud data storage costs.

At the end of the day there’s very little functionality one can use to determine if something is actually being rendered, but you can generally determine if something has been loaded and cached via http requests and such, and therefore I use the RequestQueueSize.

Sounds good, however if I divert the players camera at which point should I teleport them back? Maybe with RequestQueueSize this is possible, but I’ve heard that sometimes it doesn’t hit 0?

If it doesn’t hit zero, that means there’s a request that’s frozen or taking a long time. Could be anything from an asset that can’t or won’t load.

It should throw an error when this occurs to tell you if there’s faulty asset ID, otherwise it should hit zero.

Worst case, you can just give it a threshold to be below if you’re worried about not hitting absolute zero in any case.

Perhaps try out the IsLoaded function that prioritizes on loading the game prior before the Client entering the server virtually.

if not game:IsLoaded() then
     game.Loaded:Wait()
end

However, this function does not work with ScreenGuis since the process only works with the other customs of the game like parts and such. Not sure why the wiki doesn’t touch up on this. If you’re interested in wanting the UIs being loaded in for the player, I recommend this plugin made by @Crazyman32.

Aside from that, of course it would be advised that you create your own custom loading screen, but that shouldn’t be too difficult. Hopefully this solves the problem.

I do use the above method. But I’m referencing round based map loading. I have a server script that loads the map in and then teleports players. However, due to big chunks lagg spiking the clients don’t load the map locally before the teleport which means they teleport in seeing chunks missing.

I was doing a bit of research on this question, and apparently this is best solution you can get with this. Loading the maps piece by piece (as tedious as that sounds) in a for loop.

Using smaller chunks and also lowering my poly count I was able to fix this issue