How to clone a model into the workspace without causing lag

As the title suggests,

I have a model which I’m trying to clone and parent into the workspace every time a new game round begins, but every single time a new round begins, not sure if it’s just because of studio’s testing feature, or if it’s because the model just causes lag upon entering the workspace. It’s a simple model I threw together in studio, just meant to be a round hub, it’s a black round box with an outer layer for spectators, composed of nothing but parts.

Roblox has “Debris()” which slowly gets rid of an instance without yielding/causing lag, so my question is: Is there a reverse version of Debris() that slowly moves or clones without causing lag?

If anybody can help me that’d mean a lot, I’m a solo dev and everything I know is either thanks to kind people on Dev Forum, Youtube videos, or brute force, so any help means the world.

Have a great rest of your day, and stay safe.

4 Likes

Try out Zone Flow, Instant Map Loader by N_ckD. It seems to be right for your use case.

4 Likes

I’ll look into it, thank you yyumchi!

you might want to pool instances instead of cloning. Preload instances during server start then place it in the replicated storage then just parent it to the workspace when needed and parent it back otherwise. What causes the lag I think is the replication and re-rendering of clone to all clients each round.

2 Likes

This is a really good point when it comes to small things that are gonna be in and out of workspace but at a more faster pace, things like; vfx, projectiles, and building situations. When it comes to large scale maps you’re now dealing with less of single instances but rather models and folders with x amount of single instances along with it’s descendants or even more models and folders.

Caching here wouldn’t solve a lot and you’d still have to clone() not to mention if you care about large load times, client memory, and initial network bandwidth.

I'm referencing the flow of:

-> Server Starts
-> Server takes all maps meant for loading and puts it into ReplicatedStorage
-> Player Joins
-> Player PreloadAsync()'s the maps contents from replicatedstorage

Honestly I think if you’re going for a overkill amount of optimization here, it would be better to:

  1. keep all maps in server storage
  2. turn on Workspace.StreamingEnabled
  3. preload any map that is currently in workspace otherwise it doesn’t matter
  4. Use Player:RequestStreamAroundAsync() before spawning or teleporting or viewing
    any character/position that is anywhere near the map
  • So now you only Preload anything that is active in workspace to cut down on load times
  • Maps only exit between serverstorage and workspace negating the clients paying for
    inactive content in replicatedstorage
  • Lastly you can stream certain parts to be rendered so at least the client has some parts of the map being viewable instead of spiking the client with everything at once.

Of course this is all without trying to load/parent the map in chunk by chunk to the workspace (which you could use actors for a more seamless load).

Although this is all theory and I can’t say for sure that this will be better for 1 person or all persons with this issue. Proofs with an lower end device is the only way to say for sure :sob: because of:

1 Like

Well OP said “I have a model” so I assumed it’s just a single instance. The problem with cloning is it creates a new instance(obviously) which is replicated to all players thus the network traffic and lag especially when the model size(not the dimension) is large.
Preloading and pooling should minimize this since you are just changing the property of the instance when needed. Textures/meshes are already cached and the model is already loaded in the client, you will just need to change the parent. Much better than cloning an entire instance each round.

As for changing the parent you can just use a remote event then FireAllClients()

Note that re-parenting to workspace still needs to be re-rendered.

2 Likes

Here’s what I said regarding that model, hence my issue.

So if I just did PreloadAsync() on the models it’d basically render it just fine? Because my model is already in a folder inside of ReplicatedStorage.

should be the case if you do that and avoid Clone() like @akosibalong0 mention:

So question, to both of you, if I have the models stashed in ServerStorage, I run a script to preload all assets under ServerStorage, how would I duplicate it and get it to the workspace without cloning? Sorry I’m not the best scripter.

Sorry we must’ve confused you a little here.

So my example with

would have to do with replication but for you since it isn’t full on maps (i hope) you can do this:

My Use Case

So my method would keep all inactive maps in serverstorage and only preload any active maps inside workspace, maps wouldnt ever need to parent to replicatedstorage.

Your Use Case

For your use case players have their copy of replicatedstorage that has all the models when they join so now you can preload during loadscreens or whenever. Only thing that can be an issue here is;

  1. if a model/map is already in the workspace you won’t be able to preload from replicatedstorage and it won’t make sense to as it is set to be loaded and rendered since it is in the workspace

So now you have two cases:

  1. Player joins and model is in workspace → preload other models from replicatedstorage → so when you reparent any model to workspace its already loaded and only needs to be rerendered
  2. Player joins and model is in replicatedstorage → preload models → when you parent the model to workspace the client doesn’t need to load and render what’s been placed into workspace but rather just render the instance.
1 Like

Thank you so much for taking the time to write all this, looking into this right now

1 Like

This helped a good bit, thank you to the both of you for taking the time to help me, it really does mean a lot to me.

no problem, glad to help out!

Just to make sure that this did had some effect, I tried this on my old reliable.

keep in mind this preloads everything inside of ReplicatedStorage.Maps
when enabled

Short video

1 Like

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