Hi, I want to sync script across all my places in a single game because I’m updating the script very often. It’s a module script, and I have around 5 places where it all needs the module script. I can’t keep on copying and pasting the scripts back and forth, is there a way to sync them? Also I want to do this with some models too. Thanks!
You can upload the module script onto the marketplace and make sure the module script is named “MainModule” and make it public and make sure the places have http allow then you can copy the id of the module you just uploaded on the marketplace and require(id) then it would be load into your place. Doing this will disable the ability to have autocomplete and requiring it into your game still add up to memory.
What if I have more than one module? What should I name it if I need more than one more? Or should I just combine the modules into one?
You just do this
Make sure you select the MainModule and upload it
I did that but it doesn’t seem to work. How do I access the child module script?
Edit: I can access the module script perfectly fine, but I can’t access the children of the module script. FindFirstChild()
also doesn’t work.
Explorer:
MainModule:
Server Script
Server Script
Oh because you requiring it which mean you accessing the contain of the module script not the instance. You can make a reference for it in the module script or use InsertService#LoadAsset
Do I make a reference of it like this?
MainModule:
local module = {}
module.ChildModule = script:WaitForChild("ChildModule")
return module
Yes, very much. That how you would do it.
There’s an error that asked me “Did you make sure to name the module script ‘MainModule’?”
I think it’s because I did something wrong when publishing the module scripts. I selected both the Main Module and the child module, then right click and saved to roblox. What’s the right way to publish it?
just select the Module script
The true parent of it and upload it and make sure it named “MainModule”
Does it upload every children of the MainModule too
Yea, it should. It automatically does it.
This was introduced with this exact use case in mind.
Ohhhh right, forgot about that. Use it, I think it better
If I havea module script package in my Starter Place and also in a second place (both in the same experience), will the second place’s module script update whenever I update the Starter Place’s module script? Or do I have to manually open the second place and update the module script by myself?
IIRC, there is a studio feature to update all packages when you open a place, and there is also the AutoUpdate property of the package. However, I believe you do need to open the place and publish it to get the updated package code into new servers of the place (i.e the most update to date package is source is not pulled in live servers).
Ohhhh yes I just saw the automatically update property of packages. Will they update without me opening studio of that place?
Edit: I realized that you need to open the place and publish it for the new script changes to take effect. That will be tedious because I will have multiple places in my experience.
Hey I realized that you have to require it inside the module script like this:
local module = {}
module.ChildModule = require(script:WaitForChild("ChildModule"))
return module
Then in a server script:
local mod = require(14259815709)
child = mod.Child
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.