I already have a loading/unloading system in my game, here is how it works:
A ServerScript puts all parts of the map into ReplicatedStorage (except for models with scripts, which I call mechanical models)
I put the main map into workspace with a local script.
Then, when you click a door to enter a building, I put the main map into replicatedStorage, and take the building interior from replicatedStorage and put it into workspace.
I recently found out that objects in replicatedStorage replicate to the client (why did I not think of this, its literally in the name)
So is this how it SHOULD work?
I put parts of the map into StarterGui with local scripts.
Put them back into workspace when entering buildings.
Or do I need to do something with ServerScripts on startup?
Normally for minigame games, I use server scripts to handle the map making since it applies to everyone. Replicating to the client does take up some memory however serverstorage acts the same but doesn’t cost efficiency.
An overview of how the best way to do this
Putting all map contents for every player in ServerStorage (cannot be accessed by the client)
Cloning a random map from ServerStorage using an array and math.random
When the minigame is over, delete the map using :Destroy() or Debris:AddItem(map, lifetime)
This wouldnt be the solution, since my game loads and unloads maps ONLY for performance.
So parts of the map that the client wouldnt see would sit somewhere where they wouldnt cause extra lag, and they would get put in workspqce when needed
So you want a loading system in your game to decrease lag that works like this?
Scenario: You are exploring the town in your game and you want to enter someone’s house to complete a quest. You click on the door and the map that you were just in gets parented to replicated storage and the house interior which is parented to replicated storage gets parented to workspace.
Well your script could look something like this. (BTW so what I’m understanding you want a map loading system only for the client.)
Local Script:
DoorPart.Touched:Connect(function()
CurrentMap.Parent = ReplicatedStorage
HouseMap.Parent = workspace
– Code to teleport the player into the new house map
end)
I say just don’t do anything with the server in the first place. Do this all on client. Put it in workspace on client and when you want it to be loaded in simply parent it to game.Players.LocalPlayer.PlayerGui.