So, what I’m currently trying to do is a loading a map from replicatedstorage to workspace, because I heard there are benefits on loading maps that way. I’m doing this because many people have reported lag from the map. Even mobile users.
Here if you have to know how many parts/meshes/unions are in the map.
— COMPLETE —
Parts: 83349
Meshes: 1720
Unions: 2992
Total: 88061
Though the issue is, the maps aren’t even fully loaded, I see that It’s missing some parts, this is probably due to streamingenabled being enabled or something, because It’s not even fully loaded. I’ve tried many things to prevent that but it doesn’t seem to do anything.
I’ve tried PreloadAsync, waitforchild(), even waitforchild my player’s head, but doesn’t seem to work…
This is what I’ve got so far:
game.Workspace:WaitForChild("Map").Parent = game.ReplicatedStorage
local players = game:GetService('Players')
local localplayer = players.LocalPlayer
local char = localplayer.Character or localplayer.CharacterAdded:wait()
repeat wait() until char:WaitForChild("Head")
spawn(function()
game:GetService('ContentProvider'):PreloadAsync({workspace,game:GetService('ReplicatedStorage'),game:GetService('PlayerGui')})
end)
print("loading done")
--
local newMap = workspace.Maps
local selectedMap = game.ReplicatedStorage.Map
local totalParts = 0 -- just to see how many parts i went through
local function LoadMap(prt, parent)
if prt:IsA("Model") then
if #prt:GetChildren() > 0 then
print("Model:", prt.Name, "Children:", #prt:GetChildren())
local newModel = Instance.new("Model")
newModel.Name = prt.Name
newModel.Parent = parent
local searched = 0
for _, prtChild in pairs(prt:GetChildren()) do
totalParts = totalParts+1
if searched % 300 == 0 then wait() end searched = searched + 1
LoadMap(prtChild, newModel)
end
end
else
prt:Clone().Parent = parent
print("Cloned:", parent.Name)
end
end
local t = os.time()
LoadMap(selectedMap, newMap)
print("Map loaded:", os.time()-t, ":", totalParts)
Thanks very much in advance!