Is using "Shared" bad practice?

I’m working on a Spaceship // Plane system and have utilised ModuleScripts for this;
Instead of constantly passing Arguments between the scripts: I.E. “BodyGyro”, “Body Position” or “Status” - I’ve considered using Shared.

Now, each ship will be named after the Player it belongs to, so there shouldn’t be the clash with others. Just wondering if it’s bad practice to use Shared for this info?

3 Likes

Personally. Shared is the same as _G, just with different tables and names.

I use shared for building my entire framework on; It adds services and handles the game states inside of it. I don’t find problems and there isn’t many issues.

However, memory-wise; It is okay but its not the best. Presumably, because it will use Lua heap.

4 Likes

Would the use of Shared heavily impact performance?

There’s going to be roughly 14 - 16 Players // Ships per Server.

With this information, I only really want to share the Data and Dictionary of the reference points - Major adjustments such as Piloting etc. Will be handled ClientSide so the Shared would just be a reference point?

No it shouldn’t damage or cause problems. Its just a minimal update to optimization if you figure out another way to handle it.

You should use modules because they are a more ideal solution for sharing data across scripts.

Here’s some benefits:

  • Immediately knowing if a script depends on something or modifies it
  • Data isn’t exposed to every script and must explicitly be brought into scope (via require)

Not entirely sure why this is a problem; you can always group related data together in a table or an object which is then easier to throw around.

It’s considered a bad practice because you’re exposing data everywhere so you introduce confusion by not knowing what is modifying what.

4 Likes