Loading/unloading parts of the map

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?

Thanks in advance for helping!

2 Likes

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

  1. Putting all map contents for every player in ServerStorage (cannot be accessed by the client)

  2. Cloning a random map from ServerStorage using an array and math.random

  3. When the minigame is over, delete the map using :Destroy() or Debris:AddItem(map, lifetime)

1 Like

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)

This is literally what I already have, read the topic again

You DONT wanna parent the map to ReplicatedStorage cause it replicates, so Im looking for the best alternative

Ok just switch out the replicated storage part with the players PlayerGUI and it should work better.

This method will work well since it tricks the roblox client into not replicating it to all players.

Where do I put the map on startup?
If I keep the map in workspace ON THE SERVER, and put it in PlayerGui ON THE CLIENT it will still lag

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.

Oh yeah btw with the caps chill I know what you mean.