How to sync scripts across places in an experience

Hi,
I want to sync scripts across different places in my experience. I have successfully been able to do that with module scripts using InsertService to load it into the game, then require it.

However, when I tried the same thing with normal server scripts and client scripts, the scripts won’t run because it was created after the game started running (similar to cloning scripts, the new script won’t run)

I have tried using packages and they work. The only thing is that every time I make a change to the script package in one place, I have to open up all the other places and publish them one by one, which is very tedious. I just want to publish the game once from its starter place and have all the other script package copies to be updated as well.

So my question is, is there a way to sync scripts across different places within an experience without opening every single place when publishing? Currently, the only solution I thought of was to put all my scripts as functions into a module script, and run it like this:


--Module script
local module = {}

module.Functions = {
    function (){
        --script one
        --main server script
    },
    function (){
        --script two
        --vehicle handler
    },
    function (){
        --script three
        --shop server script
    }, 
    --etc
}

return module

Server Script:

local module = require(game.ServerStorage.ModuleScript)
for i, v in pairs(module.Functions) do
    coroutine.resume(coroutine.create(function()
        --run every function asynchronously
        v()
    ))
end

I’m wondering if there is a better way than to turn all the script into a function inside a module script. Thanks!

2 Likes