So I have some questions in the script world. I’m very new so sorry if I dumb or something like that.
1. game:GetService(“…”)
So is there any advantage of doing GetService method for services like ReplicatedStorage or Players?
2. Local/Global Functions
So Global functions can be used in other scripts so that’s the advantage. But in cases where you don’t need Global Functions I see people use Local Functions. Is there any advantage to that?
3. How to use Global Variables
So I was wondering how you would set up and use this part of scripting.
Thanks for all time you spent reading this and thanks for helping!
You should use GetService for all services (except for workspace) instead of game.AService because it’s better for maintainability but all the functions for the services stay the same.
You should learn about scopes and it will help you understand when you should use global and local variables: Scope.
You should learn about basic scope and variables to learn how to use global variables: Variables
If you have any more questions, please ask and if I don’t respond, you can always search things up.
Local variables are obtained faster than global variables because they’re integrated into the environment in which they were created. If possible, you should always use local variables over global variables, unless there’s a specific reason otherwise.
The same applies for locally defined functions as well. After all, function definitions are essentially the following.