Problem with code not running

Hello! I am working on a obby game and I have made a system where when you enter a door, it teleports you to a obby map depending on which door you entered.

The obby maps are placed in a folder in the replicated storage, and when they are spawned they are spawned from client so that way it doesn’t cause any lag for other players.

The problem I am having with this is that I have stuff in this obby map that are coded on server, and when the map is moved to workspace the server scripts no longer work, because of the map originally being parented to ReplicatedStorage.

I can’t think of how to go around this. Since the map is spawned on client, I can’t have the servers scripts in the obby map wait for the map’s parent to be in workspace as the server obviously won’t detect it.

The only option I have is to just have all the obby maps in workspace instead of having them being cloned on client for the specific player. I want to try and not do this, so I came here to see if maybe there is a way I can work around this, so the code in the obby map can run when spawned into workspace from client.

Ask any questions if you have. Any help is appreciated! :slight_smile:

1 Like

if the logic in these server scripts isn’t too important to be held on the server, then you can just change the runcontext of them to Client.

otherwise, if you really do need these scripts to be server sided, then I think your best bet would be to just have all the maps in the workspace and use streaming-enabled, so they aren’t loaded in for the player unless they’re close to it

Didn’t think about streaming-enabled. Might try to use that instead. Thanks for the help!

Actually just came across another issue.

I tried using streaming enabled but the problem is, when the player enters the door, the player never gets teleported to the spawn of the obby because it’s not loaded in for them. Not sure what I would do about this as I can’t really get them closer to the obby.

Make that obby spawns with server script, then delete it from every player (except main player) using client script.

1 Like

maybe you need to explore more about the specifics of streaming enabled, for absolutely necessary objects you can set the streaming mode to Persistent, which means it will be loaded in at all times.

streaming enabled is its own can of worms and you need to design your game around it, as your client scripts need to be ready to interact with objects as they stream in or out. (most pair it with collection service tags for stuff like killbricks)

1 Like

Why not just have all your Server scripts on ServerScriptService and have LocalScripts in the maps that send RemoteEvents?

1 Like

I’ll take all the suggestions here and see what I can do. If any other problems occur I’ll let you know. Thank you for all your guys help!