Rojo and child scripts

Rojo allows us to use VSC (or other editor) and git to handle our code better. For me, this is straightforward for scripts in ServerScriptService and modules in ServerStorage. However, when I have a GUI or a part with a child script which references the parent (e.g. part = script.Parent) I don’t know what is the best practice to use. Some things that I’ve though were:

  • I could save the whole object as a .rbxmx and add it to Rojo, but editing the script in this format is not great.
  • Write the scripts in Rojo (the scripts are not parented to their part/GUI). During runtime, some coordinator script add the correct script to each part/GUI
  • Leave the script as a child of the part/GUI and don’t add it to Rojo. To avoid leaving out a lot of logic of git, the child scripts could be only a reference to a module script registered by Rojo.
  • Use CollectionService. To be honest, I never used the service before but I recently read it could be used to deliver the same script to a group that share the same tag.
  • As a final remark, the ideal solution for me would be if Rojo handled adding children to .rbxmx the same way it handles adding children to scripts. In other words, we should be capable of adding a folder named “Model”, add model.rbxmx as child and rename it to init.rbxmx and Rojo would convert all siblings of init.rbxmx into its children inside Studio.

What do you think is the best way of adding child scripts to GUI/Parts while maintaining the code in Rojo?

1 Like

The best way to add child scripts?
Don’t. For parts, you should use CollectionService, and for GUIs, you can just find them in the PlayerGui. Rojo helped me get rid of that ugly habit.

4 Likes