Wouldn’t it be better for performance if I would make module script that store the most frequently used variables and doesn’t repeat myself in the scripts?
Example:
I don’t know if this is in the right category, but I only use modules for variables if it’s an object that changes. For example, a gun’s weapon settings will be a module.
Yes, it is in the right category I think “The Code Review category is intended to be a place where developers can get tips to improve already-working code they have created for Roblox games, or provide feedback on code of others.” I’m showing code that is working and want to know if this is better to use
For modules:
Values that are dynamic and used by multiple scripts (such as config) I would recommend using a module script so you have a one-stop place to change those variables. Additionally, I would also recommend putting functions used by multiple scripts in modules scripts.
For scripts:
Essentially everything else, this includes services, local functions, and whatever else you can think of. The reason why you would likely want to store services in the script is that they are static, and is just more common practice.
The question you actually asked
Saving variables without using a module script is always going to be more performant except in rare edge cases where the values take a lot of time to compute. The real thing though is that performance doesn’t usually matter since lua is an insanely fast language allready and I would value organization over performance in most cases.