Hi there! I have a model with about 80-something unions in ReplicatedStorage that I need to load into Workspace at certain times. Thing is, it takes a good 5 seconds to fully load everything the first time.
I'm trying to figure out a method of preloading the unions inside of the model before it's needed by the client.
I've tried two different ways of preloading unions. Keeping the model in the Workspace with all Parts and Unions with a Transparency of 1 was one idea. But it does not appear that ROBLOX renders objects when they're invisible, so the unions never got loaded.
And then there's the method I'm using currently. It moves the model into the Workspace and then back to where it started in ReplicatedStorage. The wait(.25) is required. Without it, it seems that the parenting happens so fast that ROBLOX doesn't render the model to the client, so asset loading doesn't happen.
local model = game.ReplicatedStorage.UnionedModel
local function preloadUnions()
model.Parent = workspace
wait(.25)
model.Parent = game.ReplicatedStorage
end
preloadUnions()
-- 60 is arbitrary. The model has more than 60 unions to load, so if the queue
-- size gets that big we can assume that the model is being loaded.
if game.ContentProvider.RequestQueueSize > 60 then
print("Preloading model")
end
-- After waiting a few seconds, the model is moved back to the Workspace. All
-- unions are fully loaded.
wait(3)
model.Parent = workspace
The only problem with this method is that it's inconsistent. It works very often when I run a solo test, but when I start up a server with a couple players, it will occasionally not load for one or more of the players. Using an arbitrary wait time is also not ideal, and could be the cause of the inconsistencies. An easy solution would be to increase the wait time, but I want to minimize how long that the model is rendered.
I've tried using WaitForChild to make sure that the model is in Workspace before moving it, but it still reparents before it can render. Then I tried a combination of WaitForChild and Heartbeat, which is still inconsistent.
-- WaitForChild
local function preloadUnions()
model.Parent = workspace
-- Still reparents faster than it can render
workspace:WaitForChild(model.Name)
model.Parent = game.ReplicatedStorage
end
-- WaitForChild and Heartbeat
local runService = game:GetService("RunService")
local function preloadUnions()
model.Parent = workspace
workspace:WaitForChild(model.Name)
runservice.Heartbeat:wait()
model.Parent = game.ReplicatedStorage
end
It would makes things a lot easier if I could gather up all the AssetIds of the unions in the model, but I don't think that's currently possible.
I would really appreciate some help. I've been working on this problem for hours and it's starting to get on my nerves.

4 comments
That's a very good idea. To make sure I understand, you make a copy of all the unions in a model and place them under the map so that when you move in the real model, all the unions are loaded?
Exactly. ROBLOX will load them for you when they're not fully transparent, even if they're behind walls.
Fantastic! I'll have to copy a lot of unions, but it's certainly a more reliable method than what I was using.
It's also less laggy because no scripts need be run. \o/