I’m currently working on an infinite room/map generation module and I’m a little confused about the best way to optimize the system.
I’m storing all the maps in ServerStorage, then I “preload” them by using a for loop to clone each part into the ReplicatedStorage, and lastly, I clone the entire map from ReplicatedStorage to the workspace when It’s needed by the player.
Should I also use a for loop to clone the map part by part from ReplicatedStorage to the workspace or does it not make a difference since it’s technically already been loaded on the client? Is it bad to load the entire map from ReplicatedStorage to workspace in one go?
Recap: I clone each part of the map from ServerStorage to Replicated Storage using a for loop → Then I clone the entire map at once from ReplicatedStorage to the workspace
Yes, I’ve tried finding the answer on my own by conducting online research. I’m still confused, that’s why I’m reaching out to the dev community. Any help would be greatly appreciated!
I’m not sure, everything in your game will take up some amount of memory, no matter how negligible.
Is there a reason you can’t just insert it into the workspace? Are you actually cloning on the client from replicated storage to the workspace, or are you just setting the parent?
We’re planning on having each room relatively detailed, spawning it all at once would cause a more significant spike than spreading it out with a loop.
I chose to clone each part rather than setting the parent
for i, v in pairs(selectedRoom.Decor:GetChildren()) do
task.wait(loadingSpeed)
v:Clone().Parent = roomLoading.Model.Decor
end -- Snippet of my code
Try just setting the parent directly without cloning. Also you are creating a memory leak by cloning it twice without parenting it to anything (first clone call).
If nothing works, try just cloning the whole room from server storage to the workspace. Roblox will handle replication for you.