I was trying to decrease the loading times in a game by inserting the maps via insertservice, but for some reason the 5th map inserts a shirt instead of the map.
Why does this happen and how do i solve it?
Whenever i load the map manually via 1 line of code, it inserts the map like normal.
Code for loading the maps:
local IDS = {
["Sewers"] = 5873434511,
["SSBoliviar"] = 5873433438,
["Shootem"] = 5873432578,
["QuestChronos"] = 5873431558,
["StudHarvest"] = 5873430562,
["QCherry"] = 5873428532,
["Suburbs"] = 5873426883,
["Portland"] = 5873426376,
["Subway"] = 5873424668,
["Panama"] = 5873423317,
["SummerWonderland"] = 5873422546,
["SunnySeaside"] = 5873419827,
["Outskirts"] = 5873419194,
["Terminal"] = 5873417589,
["Outpost21"] = 5873415664,
["TheComplex"] = 5873414406,
["NoMercy"] = 5873412217,
["Tokyo"] = 5873411272,
["NewHaven"] = 5873408788,
["Toy Factory"] = 5873408524,
["NewBloxcoast"] = 5873406512,
["Tutorial"] = 5873404976,
["MoltenComplex"] = 5873402425,
["USSZurius"] = 5873402082,
["Mogadishu"] = 5873398326,
["VictoriaHarbor"] = 5873398010,
["Zero"] = 5873394927,
["MSAntarees"] = 5873394897,
["LastHarvest"] = 5873386349,
["Kingstreet"] = 5873382711,
["Jacksplot"] = 5873380421,
["Foxriver"] = 5873378155,
["Farmhouse"] = 5873368816,
["District3"] = 5873365904,
["BloxHarbor"] = 5873316224,
["Bouri"] = 5873321083,
["BuriedAlive"] = 5873323185,
["Cafe"] = 5873326171,
["Campfire"] = 5873338720,
["CasinoHalls"] = 5873340774,
["Casius"] = 5873342805,
["CavedIn"] = 587334511,
["Cherry"] = 5873347786,
["ChronosXI"] = 5873350873,
["Coastline"] = 5873353423,
["Concert"] = 5873355329,
["DeadVacation"] = 5873358907,
["Deadplaza"] = 5873363779,
["Blackfield"] = 5870675514,
}
local InsertService = game:GetService("InsertService")
for i,ID in pairs(IDS) do
print("loading map")
local Time2 = time()
--local success, model,message = pcall(InsertService.LoadAsset, InsertService, ID)
local model = InsertService:LoadAsset(ID)
if model then
--repeat
--wait(0.01)
--until model:FindFirstChildOfClass("Model")
wait(0.5)
model.Parent = game.SStorage -- insert to storage to prevent twice the render
wait(0.5)
local Map = model:FindFirstChildOfClass("Model")
for i,h in pairs(Map:GetChildren()) do
if h.ClassName == "Model" then
h:Destroy()
end
end
Map.Parent = game.SStorage.Maps
else
print("Model failed to load!")
end
print("Finished loading " .. (time() - Time2))
wait(1)
end
Code for loading a single map:
local Time2 = time()
local assetId = 5873424668
local InsertService = game:GetService("InsertService")
local success, model = pcall(InsertService.LoadAsset, InsertService, assetId)
if success and model then
print("Model loaded successfully")
model.Parent = workspace
else
print("Model failed to load!")
end
print("Finished loading " .. (time() - Time2))