Hello, I am making a sort of infinite obby that works by cloning different pre-made levels.
I decided to handle the cloning of levels on the client side, because I was planning to remove levels behind the player once they are no longer needed (to improve performance).
But the problem is that each premade level uses server scripts for things such as Kill Bricks. And once I clone the premade level from the client, those server scripts stop working.
Is there a way to fix this? Or should I just handle everything from the server?
The bytecode of scripts isn’t replicated to the client so to begin with it doesn’t see any of the code needed to make things work. I would suggest turning to StreamingEnabled if you’d like an engine-bound solution that’ll automatically handle adding and removing of parts based on device memory availability.
Alternatively, have all the levels available in the Workspace when the player joins but have the client parent them out when they join. Parent back only levels that should be loaded in. This should allow the kill bricks to work but this is assuming you don’t put the code that kills players in the bricks and instead have a single script handling the kill bricks. Think that should work.