I have a folder called DataHub located in Workspace, which contains several IntValues and StringValues. Multiple scripts access and use these values for their tasks.
Today, I learned how to use Global Variables and am considering if it would be better for performance to store all these values in a script within ServerScriptStorage as Global Variables instead of using the current setup.
This approach would make performance worse, as global variables require an additional table lookup to be accessed.
Also, simply defining your variables like that will not make them accessible outside of the script they were defined in. You’d instead have to use something like _G, which is not recommended. If you want variables easily accessible from anywhere, you should use a ModuleScript.
If you don’t use the word local it doesn’t become global as in global to all scripts. It becomes global to that single file. If you want a global variable for all scripts you can use _G or shared. It’s not recommended to do so for organization purposes and instead you should use ModuleScripts.