Hi there. I’m a developer for Noob Tower Defense. We have a lot of humanoids with a lot of hats/meshes/shirts in 1 package which our game loads using InsertService.
This package is massive, and takes a full 6 to 10 seconds to load each time, which causes a massive lag spike and makes the game un-playable for that time. We’re using :LoadAssetVersion(). We use packages as these characters need to be replicated across multiple places.
I’m aware that this isn’t the best way of doing this, but this is a pretty old system written by someone else that I don’t want to rewrite unless I absolutely have to. So I’m asking here if anyone has advice on if it’s possible to make this faster or not lag the whole server. If not, no worries and I’ll probably rewrite it to either split the large package up into smaller packages or find some way of reducing the total size.
local success, result = pcall(function()
local lastest_version = InsertService:GetLatestAssetVersionAsync(UnitSkins_AssetID)
return InsertService:LoadAssetVersion(lastest_version) :: Instance
end)
Preloading is the best and simplest option if you dont want to rewrite, store any loaded in replicated storage- should not affect server load at all besides the preload part.
Multithreading difference would be useless here because LoadAssetVersion yields regardless. That’s where your wait time is coming from, not because your code cant execute fast enough.
This being said, as stated above, if you’re loading 30 assets back to back on the same serial thread, those wait times add up. Take a look at roblox’s rate limits, and see if you can make multiple requests at once. Best thing to do would be to write a module that manages and throttles all of that traffic, and caches returns.
If you really want to go crazy with this, you could go as far as to break up the assets into smaller chunks further decreasing load times.
local function FastLoad()
task.spawn(function()
local success, result = pcall(function()
local lastest_version = InsertService:GetLatestAssetVersionAsync(UnitSkins_AssetID)
return InsertService:LoadAssetVersion(lastest_version) :: Instance
end)
end)
end
This won’t solve anything. It’s not loading several smaller assets, it’s loading 1 large asset. I’m looking for a way to do it without needing to split up the package as that’ll be really painful and take a while. I already know how to load several things in parallel.