Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Which method is the best way to load a map into the game?

Currently, I am working on the core game mechanics in my place, and I'm stuck with a decision. Do I load in maps using InsertService() or do I load them in by having the maps in my game already, and then cloning them into the workspace? Will the second method break any map scripts? Will the fact that the map is just sitting there in my game's ServerStorage slow down performance?

Method #1

local map = game:GetService("InsertService"):LoadAsset(13456733)
map.Parent = workspace			

if workspace:FindFirstChild("Model") then
	for _,ungrouped in ipairs(workspace.Model:GetChildren()) do
		if not ungrouped:IsA("Terrain") and not ungrouped:IsA("Camera") and not ungrouped:IsA("Folder") then
			local u = ungrouped:Clone()
			if u then
				u.Parent = workspace
			end
		end
	end
end
workspace.Model:Destroy()

Method #2

local map = game.ServerStorage.Map1:Clone()
map.Parent = workspace

4 comments

0

don't post opinion-based questions

0

This isn't opinion based, I'm looking for an answer that is backed up with facts.

0

No its opinion based.

0

Ok fine whatever you say

1 answer

✓ Accepted answer

I prefer ServerStorage because:

  • It's already in the game, which means you don't have to load it through InsertService
  • If it auto-updates due to the model referred to by InsertService updating, the current server (with the non-updated scripts and such) won't break
  • You can access it like any other object, no fancy InsertService magic

InsertService may be good if:

  • You need something to auto-update, and the new version will work on old servers
  • You don't want to include something in ServerStorage
  • You're actually inserting something (i.e. a Free Model or something, which is probably isolated from the rest of the game)

Each has its own pros and cons, but here are some to start.

Don't worry about making the right choice, because there isn't much of a difference... but whether to auto-update or not is one thing you should consider.

Hope you figure it out!

3 comments

0

Wow, learned something new here, it auto updates. I'm going to fact check that, but thank you very much for you answer.

0

InsertService always loads the latest version of a particular model IIRC

0

When you call LoadAsset, I mean. It doesn't update models already inserted, but at the point of insertion, it's always the latest version, I think

This discussion is preserved as it was. New answers, comments, and votes are closed.