Map Is Loaded on Client to Save on Resources. Now what?

I’ve been looking for ways to code more efficiently in order to allow low end devices to run games well. I’ve loaded maps on the client, and I’ve accomplished that through the following steps:

  1. Player clicks a door and the client invokes the server.
  2. The server copies the requested map to the player’s backpack and informs the client when it’s done.
  3. The client copies the map to the workplace and then fires the server to delete the map from their backpack.
  4. The server sees the client’s request and fulfills it.
  5. The client deletes any maps that exist in the Workspace except the one that they are on.

So now the map is loaded on the client. But there are portals and doors to other maps on the map that need code to function. How would I get code going that would allow the player to touch those portals or click those doors and then repeat the steps above? Decorations on the map may also require code to work, and neither local scripts or server scripts will work when place inside the object cloned to the client.

Anything on the client’s map that requires code to run won’t run unless a method is implemented, and all I can think of is utilizing local scripts in PlayerScripts that wait for the portal to exist but to use WaitForChild since they’ll issue warnings after the timeout period is over. Is it possible to use a value.changed event? If so, how?

Have you tried using ModuleScripts?

I made a map system that works similarly to what you’ve made (or somewhat similar) and it runs code through the use of ModuleScripts. (Examples shown below)

Main Script

function LoadMapScripts(Map)
    for _, Object in pairs(Map:GetDescendants()) do
        if Object:IsA("ModuleScript") then
            local API = require(Object)

Module Script:

local API = {}

function API:Run()
    print("ran script!")

return API
1 Like