Sorting, Organizing Scripts and Workplace

I am wondering how to smartly organize values and scripts. For example Jailbreak, if devs change money amount or weapon script, all other guns are sync with that one script, same with cars. How I could success that?

are you talking about something like linkedsource?

I am talking about making like for example 100 different cars, and connect it to one script without putting different 100 scripts. I am new dev, making big game is not easy when you need update 100 scripts xd

if you for example wanted 100 cars to use the same controller script, you could have a linkedsource script
then give all your other car scripts the same linkedsource. Then when the main linkedsource script is updated all of them will update at once since they are using the same linkedsource id. heres the wiki about it
(though according to that packages succeeds linkedsource so you may wanna also look at that)

So linked source is for that. Pretty interesting. Wait. linked source is deprecated

You can easily achieve this with a for loop. LinkedSource is deprecated. Loop through all the cars, run a function for each car?

Yes, instead of using Packages, its good idea to use ModuleScript? I heard that this is good too but I am not sure

1 Like

It sounds like what you’re trying to do is have one script handle multiple objects, in your case this might be a weapon or vehicle. CollectionService makes this really easy to do!

local TAG = "WhateverYouLike"

local function instanceAdded(instance)
    -- This is called when one of the objects is added
    print(instance:GetFullName(), "was added to the game")

local function instanceRemoved(instance)
    -- This is called when one of the objects is removed

-- CollectionService connections
local CollectionService = game:GetService("CollectionService")


for _, instance in ipairs(CollectionService:GetTagged(TAG)) do

You’ll then need to add tags to any objects you want your code to run on. You can do this by using a tool such as Tag Editor or running the following code in the command bar:

game:GetService("CollectionService"):AddTag(instance, yourTag)

Well, if you would like to create say hover effects or click effects for your UI buttons, it’s best to use packages to link the scripts together. That way, all of your buttons will have the same hover effects and click effects.

However, if you wanted to make custom methods or functions, then you would use ModuleScripts. It is a bit advanced to set up (it’s referred to as Object-Oriented Programming or OOP). This can be used when you are repeating the same piece of code multiple times. Say you wanted to create a custom notification system. To push the notificatiosn (as UI); instead of creating a frame, then a button, then a text, and etc…; you can use module scripts and OOP to easily do the exact same thing. A function like with parameters such as title, body text, image if any, etc (@SovereignFrost has made a post about this very topic).

Basically, you use packages to link code together and use module scripts for your storing code to execute later.

1 Like

Seems really good, and easy solution. Thanks.

Just so you know, your link to SovereignFrost’s post isn’t pointing to anything.

1 Like

Yes, thank you for notifying. It is fixed now.

1 Like