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.
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.
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:
keep all maps in server storage
turn on Workspace.StreamingEnabled
preload any map that is currently in workspace otherwise it doesn’t matter
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 because of:
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.
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.
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;
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:
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
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.